1.Topics‎ > ‎Architecture‎ > ‎Patterns‎ > ‎a.Design Patterns‎ > ‎D.Behavioral Patterns‎ > ‎

Observer Pattern

  1. Summary 
    1. It is used to implement object state change notification mechanism
    2. In practical it defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. 
    3.   Basic Observer structure Basic Observer interaction
       
       

  2. Overview Tutorials 
    1. http://www.oodesign.com/observer-pattern.html
  3. When to Use 
    1. When one object need to notify multiple object about the change of state of it`s own
  4. Examples 
    1. Event Handlers are best examples of that actually implement observer pattern
  5. Related Patterns
    1. Factory pattern - It's very likely to use the factory pattern to create the Observers so no changes will be required even in the main framework. The new observers can be added directly in the configuration files.
    2. Template Method - The observer pattern can be used in conjunction with the Template Method Pattern to make sure that Subject state is self-consistent before notification
    3. Mediator Pattern - The mediator pattern can be used when we have cases of complex cases of many subjects an many observers
    4. Model View Controller (MVC) :Observer pattern is often mentioned in conjunction with MVC due to the need to keep the views and the associated model synchronized.
  6. References 
    1. Observer Pattern on MSDN
    2. MSDN: Implementing Observer Pattern using Dot.Net