Design Pattern, Software Development

The Proxy Design Pattern In Simple Words

We should not modify existing tested codes if we can help ourselves. Instead, we could create new codes to wrap around them that provide additional features. Then, present the new codes to the client code as the original codes. That way, we only need to ensure the quality of the new codes.  Thus, we can use the Proxy Design pattern.

A Go-between

If the opening statements were insufficient to describe the pattern, think of the Proxy design pattern as creating go-between codes. For instance, a client uses the PersonService object that provides CRUD operations. Then, we make a similar object, ProxyPersonService, with additional functionality around method calls (delegate) to the PersonService’s methods.

The Proxy Design Pattern Off The Gang of Four

According to the GOF Design Patterns, the design pattern’s intent is as follows.

Provide a surrogate or placeholder for another object to control access to it.

The proxy (surrogate or placeholder) refers to the ProxyPersonService instead of the PersonService. Moreover, the client codes should use the ProxyPersonService instead of the latter. Also, the proxy delegates method calls to respective methods in PersonService. More importantly, with the Proxy design pattern, we can provide additional features in the proxy on top of the tested codes in PersonService.

Other Design Patterns

The Proxy Design pattern is only one of the structural design patterns we can use to create maintainable software applications. Check out the other design patterns on Design Patterns Are The Ultimate Toolkit For Programmers.


Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like