Mediator Pattern

Between many design patterns Mediator is one of most used in today’s software world. In this pattern, the object encapsulates the processes between other objects, without asking other objects to interfere. We are going to analyze a real-world example that uses the mediator design pattern. This pattern serves as a go-between operator, so other components communicate through this mediator. A mediator can be the therapist in a couple therapy, or an attorney acts as a mediator in a family member conflict. We run through the mediator design pattern every time we use our phone to send a message or to make a call. When we call a friend we do not communicate directly to our friend’s phone. Your request goes on your carrier service which acts as the mediator. When it accepts your request, your message is sent out to the nearby cell tower, then through the fiber optics and electromagnetic wave, it will be received by your friend.


How does the Mediator Pattern work?

  • Mediator – Coordinates communication between colleague objects.
  • Colleague – Sends a message to and receives messages from ConcreteColleague through an associated mediator.
  • ConcreteMediator – Creates colleagues and connects them to an appropriate mediator.

In a Unix system, we have three levels of granularity to get permission to access system resources: world, group, and owner, where a user can be part of more than one group, and a group can have zero or more participants.


I this would be a model of a software, we would need to couple User Objects to Group objects and vice versa. So, every change would affect both classes. In this case, the Mediator pattern sponsors the many-to-many relationship between objects. Using enhance encapsulation allows the behavior of interrelationship to be accessed and modified/extended not only in the parent classes but also through subclasses. As a result, the Mediator pattern is the perfect way to design the user-group capability of an OS. It provides non-invasive and flexible ways to manage the member of groups and the user. The Mediator is a competing pattern. It abstracts and encapsulates arbitrary communication and relationship between colleague objects, adds new functionality and it is known by all subclasses.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s