Intent
Define an object that encapsulates how a set of objects interact. Mediator
promotes loose coupling by keeping objects from referring to each other explicitly.
Applicability
- reusing an object is difficult because it referes and communicates with
many other objects
- a set of objects communicate in well-defined but complex ways
- a behavior that is distributed between several classes should be customizable
without a lot of subclassing
Structure
[to do: diagram with Mediator and Colleagues]
Consequences
- colleague classes become more reusable
- limits subclassing
- centralizes control
- less opportunities to replace objects to change the behavior
Implementation
- Mediator as an Observer, Colleagues act as Subject
- straightforwared in IBM Smalltalk with callback Observer variation
- abstract Mediator class is often not needed in Smalltalk
Uses in JHotDraw