Question

Also, when i need to communicate between loosely coupled objects (for example, MVVM's ViewModel's), different books and blogs about best programming practices suggest use Mediator/EventAggregator patterns. My question is about differences/relations between those patterns. Can anyone describe them for me?

Was it helpful?

Solution

The two are mostly used for the same reason; reducing coupling between classes. I have even seen implementations of both, doing exactly the same thing, namely passing information as a middleman from one object to another, without them knowing about each other.

However, (my interpretation is that) the difference lies in how the Mediator (should) encapsulate behavior, i.e. complex communication between objects, while an EventAggregator/MessageBus simply enables objects to subscribe to/publish events/messages without knowing who sent or will receive it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top