The American Heritage dictionary defines the word mediator as "one that mediates, especially one that reconciles differences between disputants." In this manner, the mediator pattern usually implements a single object that becomes a shared resource through all of the different pieces of an application. It's a higher-level version of pub/sub in that it's commonly used to communicate across the different features of an application in contrast to being used within one feature to communicate with all of the individual pieces of that same feature.
"Understanding the similarities and differences between an event aggregator and mediator is important for semantic reasons."
- Derick Bailey
This article is part of a series called JavaScript Design Patterns.
Advantages
- Reduces the communication relationship from "many-to-many" to "many-to-one"
- Helps us pinpoint dependencies
- Excellent at decoupling objects which often promotes smaller, reusable components
Read full article from The Mediator Pattern
No comments:
Post a Comment