Understanding observer design pattern
In the software world, multiple services interact with each other to perform huge operation.Services can perform multiple operations, but the operations are dependent upon the objects of the services that it interacts with.
Let us assume that you follow every blogs posted in debuggers hub. To check out new blogs posted or edited you need to subscribe debuggers hub.There would be multiple subscribers that are also registered with this blog.So whenever there is a new blog posted to debuggers hub , you will be notified, or if there is a change on the published blog, you are also made aware of the edits. The way that debuggers hub notify you could be through email or any other notification mechanism defined by the observer.
The main intentions of observer pattern are listed below:
The core concept of observer pattern is to maintain one to many dependancy between objects. It makes sure that any change in one object will be notified to other dependent objects automatically
Encapsulates the core component of the subject.
There are three main participants in observer design pattern:
Real World implementaion of observer design pattern
View the code as well as output in the github source:
We will go through proxy design pattern in the next topic of design patterns in python.