What are the usage scenarios of Proxy pattern?

What are the usage scenarios of Proxy pattern?

Ninja Asked on 18th September 2018 in Design Pattern.
Add Comment
1 Answer(s)
Best answer

Proxy design pattern allows you to create a wrapper class over real object. Wrapper class which is proxy, controls access to real object so in turn you can add extra functionalities to real object without changing real object’s code. Some of the situations when the Proxy pattern is used are:

  1. Remote Proxy: Represents an object locally which belongs to a different address space. A stub in RMI is an example of proxy implementation in Java. The stub provides a local representation of the object which is present in the different address location. Web services providing interfaces accessing a remote implementation is also an example for Proxy pattern.
  1. Virtual Proxy: Used in place of a complex or heavy object. When an underlying object is huge in size, just represent it using a virtual proxy object and on demand load the real object. This provides lazy initialization to create expensive objects on demand.
  1. Protection Proxy: Controls access to the original object. Protection proxies are useful when objects should have different access rights. An example for this is the Proxy server which provides restrictive access to internet inside work place.
  1. Smart Reference: Provides additional actions when the proxy object is accessed. For example smart reference helps to keep track (count) of the number of references that are held for a particular object.
Ninja Answered on 18th September 2018.
Add Comment