Proxy Pattern

Classification : Structural Pattern(Proxy), Creational Pattern(Lazy Initialization)

Find the code example here.

In this pattern, we create a proxy for the original class that we are trying to use. This class will have all the methods(which we are interested in) of the original class and may or may not have extra methods. When we say proxy has the methods of original object, we mean the method signature. So using proxy object will be similar to using the real object.

Why use proxy pattern? Its because using the real object is more expensive. Read about it hereĀ http://www.oodesign.com/proxy-pattern.html

Proxy pattern is used in Java RMI. But its not limited to RMI. We can use it in those situations where object creation is expensive. So instead of using real object we’ll use proxy object. We call methods of the Proxy object, and the proxy will then call the method of the real object.

Share Comments
comments powered by Disqus