GoF Statement of Intent:![]() |
Defines a one-to-many dependency between objects so that when one
object changes state, all of its dependents are notified and updated
automatically. |
Brief Overview:![]() |
The basic idea is the Publisher-Subscriber relationship. One object (the subject) maintains a list of its "dependents" (the observers) and notifies them automatically of any state changes which they want to know about. The subject notifies them by calling one of their methods. This method may just be to pass a reference to itself so that the observers can then "call back" to get the data they need. |
UML Diagram: |
![]() |