This pattern provides a mediator class which normally handles all the communications between different classes and supports easy maintenance of the code by loose coupling. Web api exposes only one ExecuteCommand REST method, wich is wired up using mediator pattern to the command handlers. Mediator enables decoupling of objects by introducing a layer in between so that the interaction between objects happen via the layer. The mediator pattern's publish and subscribe pattern solves this by making the module subscribe to an event instead of directly interfacing with the other modules. Mediator Pattern Implemented In .NET/C# 9 minute read Updated: January 07, 2019 The mediator pattern or the “domain whisperer” as I like to call it has been around for a long time and the main selling point of it is the reduction of coupling and enforcing clear … This pattern defines an object which encapsulates how the objects will interact with each other’s and support easy maintainability of the code by loose coupling. A couple of years back, I had to help out on a project that was built entirely using the “Mediator Pattern”. The pattern lets you extract all the relationships between classes into a separate class, isolating any changes to a specific component from the rest of the components. The Mediator Pattern is a good choice if we have to deal with a set of objects that are tightly coupled and hard to maintain. The mediator acts as a collection of callbacks/subscriptions that are fired when events are published. This article explains what is mediator pattern and how to implement mediator design pattern in C#. If the objects interact with each other directly, the system components are tightly-coupled with each other that makes higher maintainability cost and not hard to extend. This is not something I'm planning to do nor need, its just an idea and wanted to read some feedback on it. Client app uses mediator pattern too, the mediator job is to reach the web api (send serialized command definition, etc.). Throughout this article we’ll investigate the mediator design pattern using a real world example. Define an object that encapsulates how a set of objects interact. Otherwise, each of these classes will have references to the other classes in order to interact, when required. This would result in a spider web type system classes. Mediator Design Pattern allows multiple objects to communicate with each other without knowing each other’s structure. The mediator pattern is a behavioral design pattern that promotes loose coupling between objects and helps to organize the code for inter-object communications. C# Cloud Application Architecture – Commanding via a Mediator (Part 1) November 28, 2017 by James If you're looking for help with C#, .NET, Azure, Architecture, or would simply value an independent opinion then please get in touch here or over on Twitter . There were all these presentations about the “theory” behind the Mediator Pattern and how it was a real new way of thinking. Mediator design pattern is useful when there is complex communication between the several classes that are involved in the application. This pattern defines an object which encapsulates how the objects will interact with each other’s and support easy maintainability of the code by loose coupling. Mediator design pattern comes under behavioral design pattern category of Gang of four (GoF) design patterns. This way we can reduce the dependencies between objects and decrease the overall complexity. Advantages of Mediator Pattern and how MediatR can help us This "anonymous" subscribing results in partial loose-coupling. Mediator design pattern is one of the important and widely used behavioral design pattern. A couple of years back, I had to help out on a project that was built entirely using the “Mediator Pattern”. Mediator Design Pattern Intent. Design patterns are used to solve common design problems and reduce the complexities in our code. You can think of a Mediator object as a kind of traffic-coordinator; it directs traffic to appropriate parties based on its own state or outside values. The purpose of the Mediator Pattern is to manage the complexity of the system by handling how they interact with each other. To implement this architecture, we can use a third-party library, like MediatR (Mediator Pattern) which does a lot of groundwork for us.