There might be several represetations for an object. When the state of the object changes, the represetations should all be updated. A basic model is to register each representation to the object and the object inform them when necessary. These represetations are instances of Observer model, which is presented in the following figure:
The Observer decouples the representation of data and the data themselves. The broadcast model can be modified so as to be more efficient in some cases.
Sometimes, an Observer might observe several Subjects, then it has to look up for whoever has changed when it gets a request. To manage a complicated updating procedure of several objects, it'd be better to adopt a manager so abate the expense of frequent calling Observers.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment