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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s