Dofactory.com
Dofactory.com
 Back to list
Views:   11.3K
Replies:  1
Archived

Difference between Proxy Pattern and Observer Pattern

What's the difference between the Proxy Pattern and the Observer Pattern?  Does the Observer provide more flexibility to handle events when compared to the Proxy?

Thanks for your help
Anderson Borges, Aug 31, 2011
Reply 1
The Observer Pattern is used by a publisher object to notify subscriber objects with information. The publisher object does not know the subscribing objects - except that the conform to a certain subscriber interface. This is a very flexible pattern for distributing events, since those that wants to listen on certain object has the power to do so without changing the code of the publishing object.

The Proxy Pattern is used for wrapping a kind of special object with 1 or more other objects. Either because you don't always have the wrapped object or because it needs to be managed in a certain way that can be simplified via the proxy object(s). This is kind of a way to exchange the API of an existing class with a proxy class. We are not just talking events here, but whatever kind of functionality to define via the proxy object instead of the real object.

I hope above makes sense for you as well :)

Kind Regards,

Keld Ølykke
Keld Ølykke, Sep 01, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.