Observer
Implementation
Several issues related to the implementation of the dependency mechanism are discussed in this section.
-
-
-
-
-
-
-
Specifying modifications of interest explicitly.
You can improve update efficiency by extending the subject's
registration interface to allow registering observers only for
specific events of interest. When such an event occurs, the subject
informs only those observers that have registered interest in that
event. One way to support this uses the notion of
aspects for Subject objects. To register
interest in particular events, observers are attached to their
subjects using
void Subject::Attach(Observer*, Aspect& interest);
where interest specifies the event
of interest. At notification time, the subject supplies the changed
aspect to its observers as a parameter to the Update operation. For
example:
void Observer::Update(Subject*, Aspect& interest);