Difference between revisions of "Proxy"

From CDOT Wiki
Jump to: navigation, search
Line 10: Line 10:
 
==Proxy Design Pattern==
 
==Proxy Design Pattern==
  
When a request is made to a Proxy, the real object is then instantiated and from then on any further requests are made to the real object. There are many situations in which a proxy pattern is required:
+
When a request is made to a Proxy, the real object is then instantiated and from then on any further requests are made to the real object. There are four common situations where a Proxy pattern is required:
 +
<br />
  
 
<ul>
 
<ul>
Line 23: Line 24:
 
       first referenced, and checking that the object is locked before access so that no other
 
       first referenced, and checking that the object is locked before access so that no other
 
       object may change it.</li>
 
       object may change it.</li>
 +
</ul>
 +
<br />
 +
 +
There are several other proxy pattern situations less common in design:
 +
<br />
 +
 +
<ul>
 +
  <li><b>Copy-on-Write Proxy</b></li>
 +
  <li><b>Cache Proxy</b></li>
 +
  <li><b>Firewall Proxy</b></li>
 +
  <li><b>Synchronization Proxy</b></li>
 
</ul>
 
</ul>
  

Revision as of 18:07, 16 January 2007

The Proxy pattern is used in software development to create a placeholder for an object. The object is not actually created until the information that the object holds is required. This extra layer of abstraction saves time when a program must access a database or a disk for the information.

If the information is never required, the database/disk will never be queried and the system will run more efficiently with less slowdowns for unnecessary materializations.

Proxy Design Pattern

When a request is made to a Proxy, the real object is then instantiated and from then on any further requests are made to the real object. There are four common situations where a Proxy pattern is required:

  • Remote Proxy - provides a local representative that is located in a different address space.
  • Virtual Proxy - creates expensive objects only when that object's information is required.
  • Protection Proxy - provides access controls for different clients to a specified target object.
  • Smart Reference Proxy - performs additional actions when a specific object is referenced such as counting the number of references, loading an object into memory when first referenced, and checking that the object is locked before access so that no other object may change it.


There are several other proxy pattern situations less common in design:

  • Copy-on-Write Proxy
  • Cache Proxy
  • Firewall Proxy
  • Synchronization Proxy

Links

BTP600
Wikipedia article on the Proxy Pattern