From the course: Python: Design Patterns

Proxy

- [Instructor] Proxy becomes handy when creating a highly resource-intensive object. The problem we need to solve here is postponing our object creation as long as possible due to the high-resource requirement of the object we are creating. Therefore, there's a need for a placeholder that will in turn create the object when its creation is absolutely necessary. Here's our scenario. We create an instance of a producer class only when it's available, because only a fixed number of producer objects can exist at a given time. Our proxy is an artist who is checking to see if the producer becomes available for a guest. And the proxy design pattern clients interact with a proxy object most of the time until the resource intensive object becomes available. The proxy object is in charge of creating the resource intensive objects. Adapter and decorator are related to the proxy design pattern.

Contents