Difference between revisions of "OOP Class13"

esse quam videri
Jump to: navigation, search
Line 1: Line 1:
[[Category:Object Oriented Programming]]
+
[[Category:IAM Classes]][[Category:Object Oriented Programming]]
 +
[[Category:Programming Language Concepts]]
 +
[[Category:C Sharp]]
  
 
Review Strategy Pattern
 
Review Strategy Pattern

Revision as of 19:38, 7 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.


Observer.gif

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

ObserverStocks.png


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