The observer pattern is yet another design pattern that is widely used when developing applications or software. The observer pattern is useful when one object is dependent on the state of another object. This pattern defines one-to-many dependent models between the objects. Whenever an object changes its state, all the dependent objects are notified of the change and they are all updated with the new state information. Instead of periodically checking to see whether the object has changed, it's better to notify the objects that will take the new state information upon the notification. The object that changes state is called State and the other observing objects are Dependent objects:
The preceding diagram represents a one-to-many model. With this, the state information is changed in a state object and a notification is then sent to many...