Imaging having a number of objects interacting with each other directly. As the number of objects increases, this type of direct interaction can lead to a mess. It also reduces the scope for reuse.
The Mediator pattern can be used to design a controlled, coordinated communication model for a group of objects, eliminating the need for objects to refer to each other directly.
The Mediator pattern suggests abstracting all object interaction details into a separate class, referred to as a Mediator, who knows how the objects interact. Objects no more interact directly but all the messages go through Mediator.
Mediator is different from Facade since Facade provides a higher level interface but Mediator does not. Also Facade is not known to the subsystem components but all the objects know about Mediator.
One way of implementing the pattern is as follows:
Sometimes ConcreteMediator may extend participating objects instead of their interface.






