Proxy Pattern: How a Surrogate Object Controls Access Without Changing Interfaces
The Proxy Pattern is a structural design pattern that places a surrogate object between a client and a real object to control when and how the real object is accessed. It addresses common performance issues like the N+1 query problem by delaying the loading of heavy objects, such as database relations, until they are actually needed. The pattern shares structural similarities with the Decorator pattern but differs in intent: while Decorator adds behaviour, Proxy manages access. Several variants exist for specific use cases, including Virtual Proxy for lazy loading, Protection Proxy for permission checks, Cache Proxy for storing results, Remote Proxy for network calls, and Logging Proxy for auditing. By intercepting access transparently, the Proxy Pattern allows developers to improve performance and enforce security without modifying existing client code or business logic.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in