"Design Mode Design Pattern" Reading Notes

xiaoxiao2021-03-06  15

"Design Mode Design Pattern" Reading Notes

PROXY mode

structure

purpose

When accessing an object is relatively large, you can generate an agent (Proxy).

application

Remote Proxy Remote Agent, with a local object agent remote object

Virtual Proxy virtual agent, only a cost-to-expensive object only when you need it (On Demand)

Protection Proxy Protection Agent, controls access to objects

Smart Reference Function Pointer

Differences with other modes

1. Difference to Adapter: Adapter generates a different interface for the target object to meet the needs of the user; Of course, in the protection agent, Proxy's interface can be a subset of the interface of its target object, thereby reacting those interfaces that have no right access.

2. Difference to Decorator: Although proxy and decorator are very similar, their purpose is different; the purpose of Decorator is to increase functionality for an object, and the purpose of Proxy is to control access to objects.

Reference

"Design Pattern" Gang-Of-4 1997

转载请注明原文地址:https://www.9cbs.com/read-45764.html

New Post(0)