Consequences and Comparison
In this lesson, we will compare reactor and observer patterns and explain the consequences of using the reactor pattern.
We'll cover the following...
Comparison of Reactor and Observer
Although the mechanisms used to implement them are related, there are differences between these two
patterns. The main difference is in the notification mechanism. As a Subject changes its state in an
Observer implementation, all its dependents (observers) are notified. In a Reactor implementation, this relationship is one to one – a detected event leads the Reactor to notify exactly one dependent
(EventHandler
).
One typical liability of the Observer pattern is that the cohesion of the subject is lowered; besides serving its central purpose, a subject also takes on the responsibility of managing and notifying observers. With this respect, a Reactor differs significantly as its whole raison d’être is to dispatch events to its registered handlers.
Consequences
The main consequences of applying the Reactor ...