Return to site

DESIGN PATTERN: Proxy pattern

· pattern

The _____ Pattern is a design pattern that acts as an intermediary, controlling access to another object.

It allows for additional behavior or access control without altering the client's code.

* Proxy

* Decorator

* Adapter

* Bridge

#proxy #design #pattern

Answer: proxy

The Proxy Pattern is a design pattern in software development that provides a surrogate or placeholder for another object to control access to it.

It acts as an intermediary or representative, allowing you to add additional behavior, control access, or manage the lifecycle of the real object without the client code being aware of it.

broken image

Subject: The Subject is the interface or abstract class that defines the common interface for both the Real Subject (the actual object) and the Proxy.

Real Subject: This is the actual object or service that the Proxy represents. The Real Subject performs the core functionality.

Proxy: The Proxy is an object that implements the Subject interface and acts as a substitute for the Real Subject. It controls access to the Real Subject, adding additional logic or behavior when needed.

Client: The client code interacts with the Proxy as if it were the Real Subject. The client is unaware of the presence of the Proxy.

The Proxy Pattern is beneficial in various scenarios, such as lazy loading, access control, logging, or monitoring. It allows you to introduce additional functionality without changing the client code or instantiating the Real Subject until necessary.