All PatternsBehavioral
Mediator
Defines an object that encapsulates how objects interact.
Chat roomsAir traffic controlGUI components
Understanding Mediator
The Mediator pattern defines an object that encapsulates how a set of objects interact. It promotes loose coupling by keeping objects from referring to each other explicitly.
How It Works
A
B
C
D
M
⚠ Complex direct dependencies
1
Direct Communication
Objects communicate directly - complex dependencies.
1 / 4
Basic Implementation
Chat room as a mediator between users:
main.go
Loading editor...
Real-World Example: Dialog Components
UI dialog mediating between form components:
main.go
Loading editor...