Image example:
Chatting with MM online always starts with "hi, hello". "Where did you come from ?" "How old are you ?" "How tall ?" These words are really annoying. Write a program as my proxy. When I receive these words, I have set up an automatic answer. When I receive other words, I will be notified of the answer, cool.
Proxy mode:
Proxy mode provides a proxy object for an object and controls the reference to the source object by the proxy object. An agent is an action taken by one person or institution on behalf of another person or institution. In some cases, the customer does not want or cannot directly reference an object. The proxy object can serve as an intermediary between the customer and the target object. The client cannot identify the proxy topic object and the real topic object. The proxy mode does not know the real proxy object, but only holds an interface of the proxy object. At this time, the proxy object cannot be created as the proxy object, the proxy object must have other roles created and passed in on behalf of the system.
Purpose:
Provides a proxy for other objects to control access to this object.
UML structure diagram:
Abstract base class:
1) Subject: defines the public interfaces of proxy and realsubject, so that proxy can be used wherever realsubject needs to be used.
Resolution:
Proxy is based on such a frequently used technology-an object is initialized until it is actually used, proxy is used as a placeholder when it is not used. the main point of implementation in this mode is that both proxy and realsubject inherit from subject, which ensures that both interfaces are consistent.
Design Pattern _ proxy pattern