However, as more classes are added to a program, especially during maintenance and/or refactoring, the problem of communication between these classes may become more complex.This makes the program harder to read and maintain.
Defining a set of interacting objects by accessing and updating each other directly is inflexible because it tightly couples the objects to each other and makes it impossible to change the interaction independently from (without having to change) the objects.
In software engineering, the mediator pattern defines an object that encapsulates how a set of objects interact.
This pattern is considered to be a behavioral pattern due to the way it can alter the program's running behavior.
Mediator - defines the interface for communication between Colleague objects Concrete Mediator - implements the Mediator interface and coordinates communication between Colleague objects.
It is aware of all of the Colleagues and their purposes with regards to inter-communication.