Milan  Reilly

Milan Reilly

1625047500

Mediator Design Pattern in ASP.NET Core

In object-oriented programming (OOP), the programs often consist of many classes. Developers distribute the business logic and application functionality among these classes. The more classes we have, the more communication is required between those classes and sometimes this increased the complexity of the application. The programs become harder to read and maintain because any change may affect the code in several other dependent classes. To solve this problem, we normally use a design pattern called the Mediator Design Pattern. In this post, I will give you an in-depth overview of the Mediator pattern with some real-world examples. I will also show you how to implement the Mediator pattern yourself or using a very famous MediatR library.

What is the Mediator Pattern?

The Mediator Pattern is considered to be a behavioral pattern and it defines how the objects can communicate with each other. It was first introduced in the famous book “Design Patterns: Elements of Reusable Object-Oriented Software” back in 1994 but became more popular in recent years.

According to Wikipedia:

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.
Wikipedia

#design patterns #aspdotnet #aspdotnet core

Mediator Design Pattern in ASP.NET Core