The Proxy design pattern provides a surrogate or placeholder for another object to control access to it. Moreover, it is used as often as (4/5). Next, we see the UML diagram of Proxy.
UML Class Diagram
- Proxy object can extend the functionality of the target object
- Proxy pattern can separate Client and target object to reduce the coupling of the system and increase the extensibility of the program.
- Proxy Pattern has the role of mediator and protect the target object.
- it will increase the number of classes in the system design
- A proxy object is added to the Client and the target object, which will slow down the request processing speed.
- increases the complexity of the system
- Remote Proxy: Let an object with a different address provide a representative object of a region. For example, it is possible to turn a service in the United States into a part of a service in Taiwan through a proxy mode
- Virtual proxy: Postpone the creation of an object that requires a lot of resources until it is really needed. For example, if the image file is too large when loaded, a small image Proxy is used to replace the real image
- Protection proxy: This proxy is usually used to control the access rights of different kinds of Clients to RealSubject. For example: the membership level of the forum
- intelligent proxy: used to call the target object, the proxy additional some additional functions. For example: record the traffic of access
- Delayed loading: In order to improve system performance, and direct loading of the target. For example: delayed loading of attributes in Hibernate