.

Context:

"Controlled data redundancy": The state of one object must reflect the current state of another object (e.g. document and its views, server and its clients, the result of a formula and its values in a spreadsheet).

Challenge:

To keep the dependent object up-to-date at minimum cost. (The alternative of polling the data source by its observers is both expensive and intrusive).

Skill:

Participants:

Observer:

An object that reflects the state of some resource, e.g. a view. Responsible for registering a notifier over itself for modification by that resource. Knows how to respond to change notification.

Subject:

A resource whose state is reflected by other objects. Responsible for notifying its observers when its state changes.

Observer Delegate:

A command registered by an observer at its subject. Buffers subject from observer. Allows the observer to be of any type. also: Notifier.

Signature:

Subject references notifiers, each referencing an observer.

Used patterns and idioms:

Command.

Used by:

Document/view architectures.

Source:

Java.

Scope:

General.