Mediator pattern
From Wikipedia, the free encyclopedia
The mediator pattern is a software design pattern that provides a unified interface to a set of interfaces in a subsystem. It's one of the 23 design patterns described by the Gang of Four. This pattern is considered to be a behavioral pattern due to the way it can alter the program's running behavior.
Usually a program is made up of a (sometimes large) number of classes. So the logic and computation is distributed among these classes. However, as more classes are developed in 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. Furthermore, it can become difficult to change the program, since any change may affect code in several other classes.
With the mediator pattern communication between objects is encapsulated with a mediator object. Objects no longer communicate directly with each other, but instead communicate through the mediator. This reduces the dependencies between communicating objects, thereby lowering the coupling.
Contents |
[edit] Structure
The class diagram of this design pattern is as shown below:
[edit] Participants
Mediator - defines the interface for communication between Colleague objects
ConcreteMediator - implements the Mediator interface and coordinates communication between Colleague objects. It is aware of all the Colleagues and their purpose with regards to inter communication.
ConcreteColleague - communicates with other Colleagues through its Mediator
[edit] See also
- Data mediation
- Design Patterns, the book which gave rise to the study of design patterns in computer science
- Design pattern (computer science), a standard solution to common problems in software design
[edit] External links
- Mediator Pattern in Java
- Mediator Pattern in C#
- Jt JEE Pattern Oriented Framework
|