Proxy mode: provides a proxy for other objects to control access to this object.
The Subject class defines the common interfaces of RealSubject and Proxy, so that Proxy can be used wherever RealSubject is used.
RealSubject class, which defines the real entity represented by Proxy
Proxy class. Save a reference so that the Proxy can access the object and provide the same interface as the Subject interface, so that the Proxy can replace the object.
Subject Class
RealSubject class
Proxy class
(RealSubject =
Client call
Main (=
Running Effect
Proxy modes are generally divided into the following types:
First, remote proxy provides a local representation of an object in different address spaces. In this way, the fact that an object exists in different address spaces can be hidden.
WebService in. NET is an application instance in remote proxy mode.
Second, virtual proxy is used to create objects with high overhead as needed. It stores real objects that take a long time for instantiation.
In the browser, the download is optimized through the proxy mode.
Third, the Security Proxy is used to control the access permissions of real objects.
It is generally used when the object should have different access permissions.
Fourth, smart guidance refers to the proxy processing of another thing when calling a real object.