Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "OTExample Observer"

m (Index.php?title=OTExample Observer moved to OTExample Observer: correct broken title (included URL part))
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''This is a reusable implementation of the omnipresent design pattern "Observer".'''
+
===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 [[OTExample_Stopwatch | Stopwatch]] example for an example, how a plain callin-binding suffices.
+
Note, that a well designed program in Object Teams will usually not require an explicit Observer infrastructure. See the [[OTExample_Stopwatch | Stopwatch]] example for an example, how a plain callin-binding ({{otjld|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'').
+
This demo should, however, give a quick understanding to some techniques of Object Teams for all who are familiar with the Observer pattern. In fact, after studying this example you will already know most of the relevant Object Teams concept needed for most applications.
  
 +
''Note: the OTDT ships with a slightly simpler version of this pattern''.
 +
 +
====Elements of the example====
 
<table>
 
<table>
 
<tr>
 
<tr>
 
<td style="vertical-align:top;padding-right:15px;">protocol/
 
<td style="vertical-align:top;padding-right:15px;">protocol/
:ObserverPattern</td>
+
:[[OTExample_Observer/ObserverPattern|ObserverPattern]]</td>
 
<td>'''This implements the GoF pattern very straight forwardly.'''
 
<td>'''This implements the GoF pattern very straight forwardly.'''
 
Open spots are:
 
Open spots are:
* method   Subject.changeOp  which should be triggered at relevant base-level events  
+
* 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.</td>
 
* and the abstract method  Observer.update()  which should realize the Observer's reaction.</td>
 
</tr><tr>
 
</tr><tr>
 
<td>flower_example/
 
<td>flower_example/
:Bee
+
:[[OTExample_Observer/Bee|Bee]]
:Hummingbird
+
:[[OTExample_Observer/Hummingbird|Hummingbird]]
:Flower</td>
+
:[[OTExample_Observer/Flower|Flower]]</td>
 
<td style="vertical-align:top;">'''Implement some base entities'''</td>
 
<td style="vertical-align:top;">'''Implement some base entities'''</td>
 
</tr><tr>
 
</tr><tr>
 
<td>flower_example/
 
<td>flower_example/
:ObservingOpen
+
:[[OTExample_Observer/ObservingOpen|ObservingOpen]]
:ObservingClose</td>
+
:[[OTExample_Observer/ObservingClose|ObservingClose]]</td>
<td style="vertical-align:top;">'''Two applications of the Observer pattern binding the above open spots using callin and callout bindings.'''</td>
+
<td style="vertical-align:top;">'''Two applications of the Observer pattern'''<br>
 +
binding the above open spots using callin ({{otjld|4|}}) and callout ({{otjld|3|}}) bindings.</td>
 
</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>
  
 
[[Category:Object Teams]]
 
[[Category:Object Teams]]
[[Category:Object Teams Examples]]
+
[[Category:Object Teams Examples|Observer]]

Latest revision as of 05:31, 24 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 (OTJLD §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. In fact, after studying this example you will already know most of the relevant Object Teams concept needed for most applications.

Note: the OTDT ships with a slightly simpler version of this pattern.

Elements of the example

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 (OTJLD §4) and callout (OTJLD §3) bindings.
flower_example/
Main
A simple main program

Back to the top