Observer Patter:
The observer pattern allows us to set-up an automatic 1-to-Many relationship between objects. These could be any objects, but of course the M-V-C pattern comes to mind. This affords us a great mechanism by which we can keep multiple views synchronized with a single model.
To take this a step further, however, this affords us the ability to loosely couple the Views to the Models as the Models don't need o know anything about the views that subscribe to it. Instead, a controller can marry methods in the views to events in the controller. Then neither the View nor the Model need to know about each other, yet the View can still perfectly reflect the status of the model.
"A subject may have any number of dependent observers. All observers are notified whenever the subject undergoes a change in state. In response, each observer will query the subject to synchronize its state with the subject's state." -- C# Design Patterns, Cooper, pg. 314, Addison-Wesley 2003
For further reading on the Observer Pattern see:
No comments:
Post a Comment