Distributer Pattern
Intent
The distributer pattern is an active object pattern that separates the
platform specific responsibility of event/state detection from the
distribution of the those change indications to interested clients.
The Distributer pattern is an active object analog of the Subject as described
by the GOF Observer pattern.
The separation of concerns provided by Distributer pattern allows
for applications depenedent upon the state change information provided
by the Distributer to be reused on platforms where the source of the
state change is different.
Also Known As
none
Motivation
Alarm indications typically have many interested clients in a
telecommunication product. Many applications components that
rely on these alarm indications can be used on different
products and platforms, where the source of the alarm varies.
By separating the software that determines the state
of the alarm indications (Controller) from the software that
distributes those state indications (Distributer), only the
Controller will need to be rewritten for the new platform.
Applicability
This pattern is very useful in applications where asynchronous
state changes (events) must be distributed to many clients, and
the application may execute on more than one platform.
Structure
Participants
There are three participants in the Distributer state pattern.
The Distributer itself is responsible for disseminating state change
information to Clients using the
Notification Pattern.
The Controller is responsible for determining the current state
of the distributer using system specific means. For example,
one implementation of the Controller might handle an interrupt
from a particular piece of hardware on one system, and another
implementation might poll a different hardware device on another
system.
Note that the Distributer implementation does not change and that
the Distributer knows nothing of its Clients or Controllers.
Collaborations
The Controller determines the current state by system specific
means, and sends change-of-state requests to the Distributer
as required.
In response, the Distributer stores the current state and
and notifies any appropriate clients which have requests
pending with the distributer. The Distributer typically
maintains a linked list of pending requests.
The Distributer has the role of the Subject and the Client
has the role of the Observer as described in the
Notification Pattern.
Consequences
How does the pattern support its objectives? What are the trade-offs
and results of using the pattern? What aspect of system
structure does it let you var independently?
Implementation
What pitfalls, hints, or techniques should you be aware of when
implementing the pattern? Are there language-specific issues?
Related Patterns
The Notification Pattern
describes the relationship between the Distributer (Subject) and
the Client (Observer). The difference lies in the Distributer's
implementation where the Controller is seperated from the
Distributer. Thus, the cause of Distributer state changes may
vary independently of the means of notifying clients of those
changes.