Wednesday, January 1, 2014

Proxy Pattern

A proxy functions as an interface to something else. Proxy can interface to a network connection, complex object, file etc. The operations performed on proxy is forwarded to the original object it can also provide additional functionality if required.

Types of proxies,

  • Virtual proxy : placeholder for expensive to create objects. The real object created only when client accesses it
  • Remote proxy: local representative to an object resides somewhere else
  • Protective proxy: Controls access to master object
Use proxy if you want the access to the object to be controlled or additional intermediate functionality should be provided.

Difference with Adapter Pattern

Adapter pattern allows unrelated interfaces to work together by adapting to a common interface which again implemented by Adapter classes. This adapter class will contain a property for each unrelated interface.

Whereas proxy is creating a interface on top of another interface or a class to get access. Both may look same but serves two different purposes. Adapter is like having multiple proxy classes for each interface.

Both uses wrapper classes but serves different purposes.



Wikipedia
https://sourcemaking.com/design_patterns/proxy

0 comments:

Post a Comment

Powered by Blogger.


Software Architect at Surge Global/ Certified Scrum Master

Experienced in Product Design, Software Engineering, Team management and Practicing Agile methodologies.

Search This Blog

Facebook