Answer the question
In order to leave comments, you need to log in
Chain Of Responsibility vs Event Bus, what is the fundamental difference?
Hello,
What is the fundamental difference between the Chain of Responsibility and Event Bus patterns?
Chain of Responsibility is needed to weaken the connection between entities, give the system flexibility, and the possibility of multiple processing of a single incoming request.
The Event Bus solves the same problems, and when implemented with a break in the processing chain, exactly the same effect is achieved as Chain Of Responsibility, but with one plus in the form of the absence of the need to create chains manually, since the binding follows the event.
Suppose we are talking about receiving a response from handlers, but in this case, a similar effect can be obtained from the Event Bus.
Gentlemen, what are your thoughts?
Answer the question
In order to leave comments, you need to log in
1. If you need a processing order in the event bus, you may have problems in the system (see Temporal coupling)
2. Yes, the patterns solve similar problems, there is a difference in decentralization. In Chain if responsibility there is a manager who calls the chain in order.
While event is an event, a fact, one module throws an event and it doesn't care who will process it and who is interested in this event.
Event handlers do not know about each other and do not rely on other handlers in any way, and no event handler can stop further processing of the event. (So events in js with their stopPropagation(), or "events" in some frameworks, are not exactly events).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question