The Proxy Design Pattern is a structural design pattern. that provides a surrogate or placeholder for another object to control access to it.
This pattern comes in handy when we want to add an extra layer of control over the access to an object, such as lazy loading, access control, or logging. In C#, the Proxy Design Pattern is commonly used to create a surrogate object that represents another object.
We can also say that the Proxy is the object the client calls to access the real object behind the scene. Proxy means in place of or on behalf of. That means, In the Proxy Design Pattern, a class represents the functionality of another class.
Component of Proxy Design pattern
- Subject: This is an interface that defines the members that will be implemented by the RealSubject and Proxy class so that the Proxy can be used by the client instead of the RealSubject. In our example, it is the ISharedFolder interface.
- RealSubject: This is a class that we want to use more efficiently by using the proxy class. This class should implement the Subject Interface. In our example, it is the SharedFolder class.