Intent
Define an object that encapsulates details and other objects interact with such object. The relationships are loosely decoupled.
Where to use & benefits
- Partition a system into pieces or small objects.
- Centralize control to manipulate participating objects(a.k.a colleagues)
- Clarify the complex relationship by providing a board committee.
- Limit subclasses.
- Improve objects reusabilities.
- Simplify object protocols.
- The relationship between the control class and other participating classes is multidirectional.
Structure

Participants
Mediator (ICommandMediator)
defines an interface for communicating with Colleague objects
ConcreteMediator (CommandContainer)
implements cooperative behavior by coordinating Colleague objects and knows and maintains its colleagues
Colleague classes (CommandColleague)
each Colleague class knows its Mediator object and communicates with its mediator to communicate with other objects
Example
In the demonstration application, the shape (Rectangle, Trinagle, Circle) objects communicates with CommandContainer class to issues the commands (encapsulated as Command object) to draw the shape, by extending the CommandColleague classs which holds the information about the mediator object. Here, only one way communication is implemented, since the other way communication is not necessary.
Class Diagram
