Proxy
- Provide a surrogate or placeholder for another object to control access to
it.

- Proxy
- maintains a reference that lets the proxy access the real subject. Proxy
may refer to a Subject if the RealSubject and Subject interfaces are the
same.
- provides an interface identical to Subject's so that a proxy can by
substituted for the real subject.
- controls access to the real subject and may be responsible for creating
and deleting it.
- other responsibilities depend on the kind of proxy:
- remote proxies are responsible for encoding a request and its arguments
and for sending the encoded request to the real subject in a different
address space.
- virtual proxies may cache additional information about the real subject
so that they can postpone accessing it. For example, the ImageProxy from the
Motivation caches the real image's extent.
- protection proxies check that the caller has the access permissions
required to perform a request.
- Subject : defines the common interface for
RealSubject and Proxy so that a Proxy can be used anywhere a RealSubject is
expected.
- RealSubject : defines the real object that the
proxy represents.
- A remote proxy provides a local representative for an object in a
different address space.
- A virtual proxy creates expensive objects on demand. The ImageProxy
described in the Motivation is an example of such a proxy.
- A protection proxy controls access to the original object. Protection
proxies are useful when objects should have different access rights.
- The Proxy pattern introduces a level of indirection when accessing an
object. The additional indirection has many uses, depending on the kind of
proxy:
- A remote proxy can hide the fact that an object resides in a different
address space.
- A virtual proxy can perform optimizations such as creating an object on
demand.
- Both protection proxies and smart references allow additional
housekeeping tasks when an object is accessed.