Color Of Code

  • Full Screen
  • Wide Screen
  • Narrow Screen
  • Increase font size
  • Default font size
  • Decrease font size

Observer pattern

E-mail Print

Goal

A subject object, maintains a list of its dependants, called observers, and notifies them automatically of any state changes.

UML

Observer pattern

C#

2 alternatives (More information here):

  1. Using interfaces like IObserver and IObervable and make interface calls
  2. Use an event in the subject and delegates. Observers register on this event.

The second option is completely integrated in the .NET CLR.


Last Updated on Sunday, 05 September 2010 16:50