Figure ‘Proxy and actual object’ shows how we have created an interface which is implemented by the actual class. So the interface ‘IImageProxy’ forms the proxy and the class with implementation i.e. ‘clsActualImage’ class forms the actual object. You can see in the client code how the interface points towards the actual object.
Figure: - Proxy and actual object
The advantages of using proxy are security and avoiding duplicating
objects which are of huge sizes. Rather than shipping the code we can
ship the proxy, thus avoiding the need of installing the actual code at
the client side. With only the proxy at the client end we ensure more
security. Second point is when we have huge objects it can be very
memory consuming to move to those large objects in a network or some
other domain. So rather than moving those large objects we just move the
proxy which leads to better performance.Reference:
http://www.codeproject.com/Articles/28402/Design-pattern-FAQ-part-4
No comments:
Post a Comment