Design Patterns Mediator Pattern - Design Patterns

What is Design Pattern Mediator Pattern?

Mediator pattern is used to decrease communication simplicity between several objects or classes. This pattern provides a mediator class which normally handles all the communications between different classes and supports easy continuance of the code by loose coupling. Mediator pattern fall under behavioural pattern group.


We are representative intermediary pattern by instance of a chat room where many users can send message to chat room and it is the task of chat room to explain the messages to all users. We have created two classes Chartroom and User. User objects will use Chartroom method to distribute their messages.

MediatorPatternDemo, our presentation class, will use User objects to prove communication between them.

Step 1

Create mediator class.

Step 2

Create user class

Step 3

Use the client object to explain communications between them.

Step 4

Verify the output.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Design Patterns Topics