Skip to main content

Posts

Showing posts with the label Mediator Design Pattern C#

Design Patterns for better code - Mediator Design Pattern

The mediator design pattern comes under the list of Behavioral design patterns. The mediator facilitates the communication b/w different objects so they don't have to keep the reference of each other. instead, they depend on a mediator to communicate with the other objects. Definition of Mediator Design Pattern : With the mediator pattern, communication between objects is encapsulated within 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 reducing coupling. Let's take the example of a Chat Room. One Chat Room can have multiple Team members and each message sent by any of the members will be broadcasted to all the other members. Let's say, If a Member has to send a message to Other Members it would required to have instances of all the other Team Members. You can think of this idea already, what a mes...