Command, Repository and Mediator Design Patterns

Topics covered
Popular Clips
Episode Highlights
Pattern Examples
The mediator pattern is a design approach that encapsulates how a set of objects interact, promoting loose coupling by preventing direct references between them. Michael Outlaw explains that this pattern allows an 11th object, the mediator, to manage communication among ten other objects, ensuring they operate independently while still interacting effectively 1. A practical example is air traffic control, where planes communicate through a central control rather than directly with each other 2.
All of the planes don't know. They don't talk to each other and they don't even know how to talk to each other, but they go through their traffic control and they communicate with, with that group.
--- Michael Outlaw
This pattern is also applicable in web development, where a mediator can manage interactions between web components without them being aware of each other 3.
Pattern Comparison
The mediator and observer patterns both facilitate communication between objects, but they do so in distinct ways. Michael Outlaw notes that while the observer pattern notifies all dependent objects of changes, the mediator pattern actively manages interactions by deciding what actions to take based on the changes 4. This distinction is exemplified by the air traffic control analogy, where the mediator (control tower) directs planes based on specific needs, unlike the observer pattern, which would merely broadcast changes 5.
The mediator knows how to do things to the other ones. It's not notifying the other objects. It can go do things to those objects.
--- Alan Underwood
This nuanced difference highlights the mediator's role in decision-making, contrasting with the observer's role in event notification 6.
Related Episodes
Design Patterns Part 3
Answers 383 questionsDesign Patterns Part 1
Answers 383 questionsDesign Patterns Part 4 - Adapter, Facade, and Memento
Answers 383 questions

Software Design Anti-patterns
Answers 383 questions

We're Testing Your Patience...
Answers 383 questions

Clean Code - How to Write Classes the Right Way
Answers 383 questions

Why Domain Driven Design
Answers 383 questions

Clean Code - How to Build Maintainable Systems
Answers 383 questionsBehavioral Patterns Pt 1
Answers 383 questionsClean Code - How to Write Amazing Functions
Answers 383 questions

Clean Code - Comments Are Lies
Answers 383 questions

Designing Data-Intensive Applications – Multi-Leader Replication
Answers 383 questions

Data Structures - Arrays and Array-ish
Answers 383 questions

Clean Architecture - Programming Paradigms
Answers 383 questions
Clean Architecture - Fight for Architecture
Answers 383 questions
