Static Class Structure
Subject
Observer interface
to update dependent objects (observers)
and is independent of how the objects
are updated.
observers).
attach(o), detach(o)).
notify()),
i.e., calling update()
on all registered observers:
for each o in observers: o.update().
notify()
on itself when its state changes.
Subject1
Observer
update()), i.e.,
synchronizing observer's state
with subject's state.
Observer1,Observer2,,…
Observer interface.
subject)
to the subject they observe
to get the changed data (getState).
Dynamic Object Collaboration
Observer1
and Observer2 objects
register themselves on a Subject1 object
and are subsequently
notified and updated
when Subject1 changes state.
Observer1 and Observer2
objects that
call attach(this)
on Subject1
to register themselves.
Subject1
changes,
Subject1
calls notify()
on itself.
notify()
calls update() on
the registered
Observer1 and Observer2
objects,
which in turn get the changed data (getState())
from Subject1
to update (synchronize) their state.
Subject and Observer
objects
(see Implementation).