Design Patterns : Observer Pattern
Definition
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Applicability
Use Observer pattern when
- An abstraction has two aspects, one dependent on the other. Encapsulating these aspects in separate objects let you vary and reuse them independently.
- A change to one object requires changing others, and you don’t know how many objects need to be changed.
- An object should be able to notify other objects without making assumption about who these objects are. In other words, you don’t want these objects tightly coupled.
Diagram

[Design Patterns – Gamma, et al, 1995]