1 / 5

Proxy Pattern

Proxy Pattern. Definition of “Proxy”: Authority or power to act for another Original Gang of Four pattern, much used Stands in for a “real object” (similar to a pointer) Provides a public interface to the real object. Proxy Services. Local interface Access control

wwaldron
Download Presentation

Proxy Pattern

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Proxy Pattern • Definition of “Proxy”: Authority or power to act for another • Original Gang of Four pattern, much used • Stands in for a “real object” (similar to a pointer) • Provides a public interface to the real object

  2. Proxy Services • Local interface • Access control • Resource instantiation cost reduction

  3. Types of Proxies • Protection Proxies grant or deny client access to the real subject (i.e., check permissions) • Remote Proxies are a local representation of a real subject in a different host (e.g., RMI) • Virtual Proxies represent expensive objects, such as images (e.g., replies to getHeight()) • Smart Reference Proxies can count number of times referenced, act as lock or semaphore

  4. Abstract Class Interaction Subject Client Request () ...() Generalization RealSubject Proxy Request () Request () ...() ...() realSubject Aggregation Proxy UML Representation

  5. Code Example private void init() { imgProxy = new ImageProxy (); } //Do stuff to image public ImageManipulation1() { InitializeComponent(); init(); } //Then instantiate image private initiate(object, args) { Real.Image = imgProxy.getImage (); }

More Related