A daily dose of software engineering wisdom - inspiring, thought provoking, and sometimes just plain dangerous.

Tags: observer pattern

*Observer Pattern*

Java calls this the Listener pattern.

It often occurs that one element of a design needs to take an action when another element of the design discovers that an event has occurred. Often we don't want the detector to know about the action taker. For example many different meters might want to know about changes in a sensor.

In practice the meters all implement a standard interface and register themselves with the sensor. When its state changes the sensor calls a method on each of the registered observers (listeners).

Last published: Wednesday 2nd June 2010

<<Previous     Next>>

carriagereturn.org home