Difference between revisions of "OOP Class13"
Line 1: | Line 1: | ||
− | [[Category:IAM Classes | + | [[Category:IAM Classes]] |
− | |||
− | |||
Review Strategy Pattern | Review Strategy Pattern |
Latest revision as of 16:32, 10 June 2019
Review Strategy Pattern
Inclass Practice Final
If there is time we will review observer pattern.
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 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/gbrowser.php?file=/classsource/class13/Observer_j.cs
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
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
Practice final not graded.
Review next week