Proxy Pattern

Proxy pattern suggests using a separate object referred to as a proxy to provide a means for different client objects to access the target object in a normal way. A Proxy exists because:

  • Creation of object may be expensive so its creation can be postponed till the very need arises and till then, a proxy can represent the target.
  • The location of the target object is not known or varies.

Proxy features are:

  • The Proxy object offers the same interface as the target object.
  • Clients usually can not interact with the target object directly, unlike Facade and Decorator.
  • Proxy differs from Decorator since decorator adds functionality and does not control access to the target object.
  • Unlike Facade, the Proxy interacts with only one object.

We have different types of proxies: Remote Proxy, Virtual Proxy, Cache Proxy, Firewall Proxy, Counting Proxy, …

In Java RMI, stubs act as a Remote Proxy.

page_revision: 3, last_edited: 1213781604|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License