Design patterns are used to solve the recurring problems and complexities in designing software applications. The Gang of Four design patterns are divided into three categories: creational, structural, and behavioral. Creational design patterns are used to create and manage the mechanism of creating instances of classes. Structural design patterns are used to define the structure of types and their relationships. Behavioral design patterns are used to manage object collaboration and the delegation of responsibilities among objects. The proxy design pattern belongs to the structural category.
When working on applications, you might often need to access objects that are part of a separate application or domain. In these cases it is a best practice (for the sake of code maintenance and separation of concerns) to separate the logic used to communicate with the external application or domain from the logic used to access the object itself. This is where the proxy design pattern comes into play. The Gang of Four defines the proxy design pattern as follows:
Provide a surrogate or placeholder for another object to control access to it.
This article presents a discussion of when and why we should use the proxy design pattern and how we can implement the proxy design pattern in C#.