Skip to main content
Jump to: navigation, search

Difference between revisions of "OTExample Observer"

Line 27: Line 27:
 
</tr><tr>
 
</tr><tr>
 
<td>flower_example/
 
<td>flower_example/
:Main</td>
+
:[[OTExample_Observer/Main|Main]]</td>
 
<td style="vertical-align:top;">'''A simple main program</td>  
 
<td style="vertical-align:top;">'''A simple main program</td>  
 
</tr></table>
 
</tr></table>

Revision as of 06:47, 23 February 2010

This is a reusable implementation of the omnipresent design pattern "Observer".

Note, that a well designed program in Object Teams will usually not require an explicit Observer infrastructure. See the Stopwatch example for an example, how a plain callin-binding (4) suffices.

This demo should, however, give a quick understanding to some techniques of Object Teams for all who are familiar with the Observer pattern (the OTDT ships with a simpler version of this pattern).

protocol/
ObserverPattern
This implements the GoF pattern very straight forwardly.

Open spots are:

  • method Subject.changeOp which should be triggered at relevant base-level events
  • and the abstract method Observer.update() which should realize the Observer's reaction.
flower_example/
Bee
Hummingbird
Flower
Implement some base entities
flower_example/
ObservingOpen
ObservingClose
Two applications of the Observer pattern
binding the above open spots using callin (4) and callout (3) bindings.
flower_example/
Main
A simple main program

Copyright © Eclipse Foundation, Inc. All Rights Reserved.