Applied Design Patterns with Java
Behavioral :: Mediator (273) {C ch 20}
Applicability
Use the Mediator pattern when:
- a set of objects communicate in well-defined but complex
ways. The resulting interdependencies are unstructured and difficult to understand.
- reusing an object is difficult because it refers to
and communicates with many other objects.
- a behavior that's distributed between several classes
should be customizable without a lot of subclassing.
Structure
A typical object structure might look like this:
Participants
- Mediator (DialogDirector)
defines an interface for communicating with Colleague objects.
- ConcreteMediator (FontDialogDirector) implements cooperative behavior by coordinating Colleague objects,
and knows and maintains its colleagues.
- Colleague classes (ListBox, EntryField) each Colleague class knows its Mediator object, and each colleague communicates
with its mediator whenever it would have otherwise communicated with another colleague.
Catalog Behavioral Prev Next