문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top