OOP Class13
From IAMMediaWiki Create Change
Inclass Practice Final
http://iam.colum.edu/oop/classsource/class13/ConsoleApplication3.zip
Observer
Observer
- Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
Observers
http://www.dofactory.com/Patterns/PatternObserver.aspx
Observer is a deisgn pattern that is often used to publish (push) or subcribe (pull) changes in the stae of one object to other intersted object. It encourgaes loose coupling of objects.
The object the get the data often called the subject then notifies the observing objects of the change. The observing object will often repond to the subject.
Here is a real example in c#. In this exmaple a stock (the subject) notifies and investor (the observer) of a change in price.
http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class13/Observer_j.cs
http://iam.colum.edu/oop/classsource/class13/Observer.aspx - source
Observer App
Here's and exmaple of a windows app the uses the observer pattern
http://iam.colum.edu/oop/browser/browser.aspx?f=/classsource/class13/Observer
Here is the start of a web app that does the same
http://iam.colum.edu/oop/classsource/class13/ColorObserver.aspx - source
http://iam.colum.edu/oop/classsource/class13/ColorObserver2.aspx - source
Homework
Build a web page that uses the observer pattern.


