Summary

In this chapter, you learned how to use the Proxy design pattern. We used the Proxy pattern to implement a surrogate of an actual class when we want to act before (or after) accessing it. There are four different Proxy types. They are as follows:

  • A remote proxy, which represents an object that lives in a remote location (for example, our own remote server or cloud service)
  • A virtual proxy to delay the initialization of an object until it is actually used
  • A protection/protective proxy, which is used to access control to an object that handles sensitive information
  • When we want to extend the behavior of an object by adding support such as reference counting, we use a smart (reference) proxy

In the first code example, we created a virtual proxy ...

Get Mastering Python Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.