27-08-2012, 02:27 PM
Observer Pattern
observer design pattern.pptx (Size: 140.06 KB / Downloads: 30)
defines a one-to-many dependency between objects
assure consistency between objects
object containing the data is separate from the objects that display the data
When the state of one object changes, then all the other objects that are dependent on that object are updated automatically.
Used for event handling where consistency between objects is necessary, e.g. Swing Framework for GUI development.
The Message to the Media
We undertake two simple data conversions:
1. we get the label from the radio button and send it to the observers, and
2. we convert the label to an actual color in the ColorFrame observer.
Pros and Cons of the Observer Pattern
subject and observers can be modified independently
observers can be added without modifying the subject or other observers
A subject doesn’t know the details of any of its observers.
Need to decide which object will initiate the notification of the change to the other observers.