Lecture overview -- Keyboard shortcut: 'u'  Previous page: Patterns and Techniques [Section] -- Keyboard shortcut: 'p'  Next page: An Observer Example -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 42 : 45
Object-oriented Programming in C#
Data Access and Operations
The observer design pattern

The subject (weather service object) to the left and its three observers (weather watcher objects) to the right. The Weather Service Object get its information various sensors.

The Observer is often used to ensure a loose coupling between an application and its user interface

In general, Observer can be used whenever a set of observer objects need to be informed about state changes in a subject object

 

/user/normark/oop-csharp-1/sources/c-sharp/patterns/observer/template/subject-only.csTemplates of the Subject class and the SubjectState class.


/user/normark/oop-csharp-1/sources/c-sharp/patterns/observer/template/observer-only.csA templates of the Observer class.


/user/normark/oop-csharp-1/sources/c-sharp/patterns/observer/template/client.csApplication of the Subject and Observer classes.