Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I will focus on pros and cons of the "<code>NotificationCenter</code>" solution as required by the question (though I'd call it <code>DataBus</code>, <code>Dispatcher</code> or <code>Publisher/Subscriber</code>, instead).</p> <p><strong>Pros</strong>:</p> <ul> <li>High decoupling of the classes</li> <li>The Subscriber of an event doesn't need to know the source of the event</li> <li>Concurrency management is simplified if you use an asynchronous <code>NotificationCenter</code> (you can avoid multithreading by using the <code>NotificationCenter</code> as a scheduler of cpu time).</li> <li>An event driven architecture is higly testable / observable</li> </ul> <p><strong>Cons</strong>:</p> <ul> <li>The interface is implicit (i.e. the interface of a class does not expose the events)</li> <li>The partitioning of the application is critical, in order to avoid duplication of the state in the classes</li> <li>Reusability in another application becomes harder (when you want to reuse a class in another application, it brings with itself the <code>NotificationCenter</code>)</li> <li>It's difficult to insert a new elaboration in the flow of events from input to output (i.e.: if class <code>A</code> emits event <code>E</code> and class <code>B</code> registers for notifications of <code>E</code>, you cannot insert a class <code>C</code> "between" <code>A</code> and <code>B</code> to change the content of <code>E</code> let's say to do some kind of elaboration on it)</li> <li>The <code>NotificationCenter</code> must manage client's errors (i.e. the <code>NotificationCenter</code> should provide an exception handler to catch the exeptions thrown in the event handlers).</li> </ul> <p>In addition, I'd like to point out that it's not indispensable that the NotificationCenter be a singleton. In fact you can have multiple instances of NotificationCenter, each managing different category of events (e.g. in an embedded system you can have a NotificationCenter for the low level hardware events and another for the high level logic).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload