Design Patterns in Object Oriented Programming - Observer Pattern
From Wikipedia:
The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.
It is mainly used to implement distributed event handling systems, in “event driven” software.
The Observer pattern addresses the following problems:
Defining a one-to-many dependency between objects by defining one object (subject) that updates the state of dependent objects directly is inflexible because it couples the subject to particular dependent objects. Tightly coupled objects are hard to implement, change, test, and reuse because they refer to and know about (how to update) many different objects with different interfaces.
Shows the code without the implementation of the Observer Pattern.
Shows the code with the implementation of the Observer Pattern.