Proxy vs Observer design pattern

The Proxy design pattern allows to define a “proxy” class which will act as a wrapper object which will be called by the client to access the product object without exposing the details. This proxy class can also be used to add extra functionality without changing the product behavior. This design pattern can be used in cases to provide additional security access to an existing product or providing an interface for remote resources. General class diagram of proxy pattern is shown below.

Proxy design pattern class diagram

Please check Proxy design pattern for more information.

Observer design pattern

Observer design pattern is one of the most famous and widely used design pattern in software industry. In this design pattern basically multiple objects which are called as observers, registers themselves to an object called as subject for getting automatic notifications, whenever any state changes occurs in subject. This is mainly used for event handling modules. General class diagram of proxy pattern is shown below.

Observer design pattern class diagram

Differences between Proxy vs Observer design pattern

Proxy methodObserver method
In this method, a wrapper class is designed to protect the intricacies of the actual classIn this method, multiple objects called as observers registers themselves for a certain event to get automated notifications.
This is very flexible way to define the API to ensure minimal changes needed to be done for any interface interaction.This is a very flexible way to define automated notifications.

Leave a Reply

Your email address will not be published. Required fields are marked *