18
The Proxy Pattern
The Proxy pattern is used when you need to represent an object that is complex or time consuming to create by a simpler one. If creating an object is expensive in time or computer resources, a proxy enables you to postpone this creation until you need the actual object. A proxy usually has the same methods as the object it represents; when the object is loaded, it passes on the method calls from the proxy to the actual object.
There are several cases where a Proxy can be useful:
If an object, such as a large image, takes a long time to load.
If the object is on a remote machine and loading it over the network might be slow, especially during peak network load periods.
If the object has limited access rights. The proxy then ...
Get Python Programming with 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.