SDSU CS 635: Advanced Object-Oriented Design & Programming
Spring Semester, 1998
Observer Variants

To Lecture Notes Index
© 1998, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 21-Apr-98

Contents of Doc 8, Observer Variants

References slide # 1
Conduit of Subject Change slide # 2
Event Channel - OMG Event Service Specification slide # 4
Reactor Pattern slide # 6


Conduit of Subject Change Pattern
"Implementation Patterns for the Observer Pattern", Kim and Benner, in Pattern Languages of Program Design 2, Edited by Vlissides, Coplien, Kerth, 1996, pp 75-86

Event Channel
Pattern-Oriented Software Architecture: A System of Patterns, Buschmann, Meunier, Rohnert, Sommerlad, Stal, Wiley,1996, pp 341 343

Inside Corba: Distributed Object Standards and Applications, Mowbray & Ruh, Addison-Wesley 1997, pp 112-116

Reactor: An Object Behavioral Pattern for Concurrent Event Demultiplexing and Event Handler Dispatching, Schmidt, in Pattern Languages of Program Design 1, Edited by Coplien, Schmidt, 1995, pp 529-545

Doc 8, Observer Variants Slide # 2
Observer Variants and Similar Patterns

Conduit of Subject Change

Problem: In complex subjects it can be difficult for the observer to extract detailed change information from the subject. In such situations the observer becomes tightly coupled with the subject.

Goal: Provide a uniform mechanism for sending state change information on a subject to the observer via a message

Solution: the subject sends a structured update message object to the observer

The update message contains four lists

add list
remove list
modified list
container list

Add List contains all objects added to the state in the change

Remove List contains all objects remove from the state in the change

Modified List contains all objects modified in the state in the change

Container List contains the containers that hold the objects that were added, removed, or modified

Doc 8, Observer Variants Slide # 3

Let the subject be a car object that contains a linked list of tire objects, label it tires

Assume that the car just had two flat tires, label them frontLeft and rearLeft

The car would create a new update message object,

the add list and the remove list would be empty

the modified list would contain frontLeft and rearLeft

the container list would contain tires
The observer receiving the update message object would then search the lists to determine which parts of the car object changed and act appropriately

Doc 8, Observer Variants Slide # 4

Event Channel - OMG Event Service Specification

Subject (Supplier, Publisher) changes state (or produces an item)

Observer (Consumer, Subscriber) reacts to the change in state (or consume the item)

Classic Supplier Consumer


Push verses Pull Model

When supplier (publisher) creates a new item, it pushes it to the consumer (subscriber) whether they want it or not

When a consumer (subscriber) needs an item it requests it from the supplier (publisher), whether the item is ready or not

Doc 8, Observer Variants Slide # 5
Event Channel

Event Channel

When a push supplier pushes an item the event channel pushes the item to all its push consumers and saves the item until all its pull consumers have pulled the item

The event channel must periodically pull from all its pull suppliers. The pull can be initiated by a pull consumer or the event channel.

Doc 8, Observer Variants Slide # 6

Reactor Pattern

This pattern supports in a single process the demultiplexing and dispatching of multiple event handlers which are triggered concurrently by multiple events. The reactor pattern simplifies event-driven applications by integrating the demultiplexing of events and the dispatching of the corresponding even handlers.

This pattern is of interest to those who need to implement a concurrent server in an environment that does not support threads or multiple processes.

visitors since 24-Feb-98