> Design Patterns > Mediator Design Pattern
Mediator design pattern is used for controlling the interaction between different objects.
The intent is to have an object to encapsulate the interaction of different objects.
Too much communication between objects increases dependency between them, makes the system complex and reduces the reusability of objects. Also extending the behavior requires more subclasses.
There can be a separate object, which will encapsulate the behavior of interaction of the communicating objects. It will also have responsibility for coordinating the interaction of objects. So objects will communicate through this object only.
Here is the mediator design pattern example.
There are different application servers - ProductServer, NewsServer, PriceServer, TransactionServer, CustomerAccountServer and
they want to interact with database servers - ProductDBServer, MarketingDBServer, CustomerDBServer.
C++ | Mediator Pattern in C++ | Mediator Pattern C++ Example |
C# | Mediator Pattern in C# | Mediator Pattern C# Example |
Java | Mediator Pattern in Java | Mediator Pattern Java Example |
Python | Mediator Pattern in Python | Mediator Pattern Python Example |
JavaScript | Mediator Pattern in JavaScript | Mediator Pattern JavaScript Example |
PHP | Mediator Pattern in PHP | Mediator Pattern PHP Example |
Ruby | Mediator Pattern in Ruby | Mediator Pattern Ruby Example |
Swift | Mediator Pattern in Swift | Mediator Pattern Swift Example |
Objective-C | Mediator Pattern in Objective-C | Mediator Pattern Objective-C Example |