Album Cover

Design Patterns Vol. 3 Java

Close Preview
The Players
This pattern brings the following players to the stage:
  • Subject: the object that keeps a list of Observers and notifies them of new events.
  • Observer: an object that registers with a Subject to receive notifications of new events/information from a Subject.
  • Stimulus: the source of the event that a Subject sends to its Observers. A Subject itself may be the Stimulus.
Variations
Push Picture
Pushing an event or new information to Observers is the most common implementation for this pattern.
A Subject maintains a list of Observers, including methods to add and optionally remove Observers.
When a Stimulus is received (or when the Subject produces its own stimulus), the Subject notifies all Observers about the new information.
Observer Push Sequence Diagram
Pull Picture
Observers pull events or new information from Subjects when it is expensive to push that information to all Observers.
Observer Pull Sequence Diagram
(Reading...)
| Tweet...
Page rating: | Rate this Page