OOP Class13

esse quam videri
Revision as of 16:32, 10 June 2019 by Janell (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Review Strategy Pattern

Inclass Practice Final

If there is time we will review observer pattern.



Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.



Observer is a design pattern that is often used to publish (push) or subscribe (pull) changes in the stae of one object to other interested object. It encourages 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 respond to the subject.


Here is a real example in c#. In this example a stock (the subject) notifies and investor (the observer) of a change in price.



http://iam.colum.edu/oop/classsource/class13/Observer.aspx - source

Observer App

Here's and example of a windows app the uses the observer pattern


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


Practice final not graded.

Review next week