Proxy Pattern


  • The Proxy pattern supports objects that control the creation of and access to other objects.
  • The proxy is often a small (public) object that stands in for a more complex (private) object.
  • Proxies are interfaces to classes that have sensitive data or slow operations.

Different Types of Proxies

Virtual proxies

  • Hands the creation of an object over to another object.
  • Useful if the creation process might be slow or might prove unnecessary.

Authentication proxies

  • Checks that the access permissions for a request are correct.

Remote proxies

  • Encodes requests and sends them across a network.

Smart proxies

  • Adds to or changes requests before sending them on.

Class diagram: (see Proxy Pattern code review)

Proxy Pattern class diagram of sample code download


Use the Proxy pattern when you have objects that:

  • Are expensive to create.
  • Need access control.
  • Access remote sites.
  • Need to perform some action whenever they are accessed.