Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A good analogy is that of a telephone exchange, where every handset can dial to every other handset. A compromised handset can tune into other conversations. Program control flows like wires(cyclomatic complexity anyone!) This is similar to the requirement of having a connection/physical medium between two end points. This is So for N handsets instead of having NC2 (Combinatorial logic) flows for every new handset we tend to get N flows.</p> <p>A reduction in complexity implies easy to understand code. Lets start with the prominent points you have highlighted: 1. Global knowledge 2. Intrusive modifications.</p> <p>Global Knowledge: Consider message event to be an envelop. From event handler/sender perspective there is no data being exposed, it is seeing an envelop (unless an derived class tries to do some inspection using 'instanceof' checks). In a good OOP design, this would never occur.</p> <p>Intrusive modifications: Instead of having a event specific listener approach, one can use a global event handling approach. As such we have a global event type (on which data is piggy backed and down-casted). This is much like the PropertyBeanSupport model in Java. With a single event type we are required to have a single sender and listener types. This implies you need not modify the bus/listeners every time you see something new. The ugly down-casting can be soothened using Adapter pattern (Please don't start that another level of redirection quote!). Programmers can write assembly in any language. So need for commonsense and smartness can not be substituted. All I intend to state is it can be a effective tool.</p> <p>The actual event receivers can use the listeners (composition/proxy) easily. In such a Java code base, listeners would look like stand alone inner class declarations (with unused warning being flagged in certain IDEs). This is akeen to two players on the beach playing a ball game, the players don't react until they see the ball.</p> <p>'@duffymo' points out another interesting aspect: 'Single point of failure'. This would/can in theory effect any object residing in memory(RAM) and not specific to MessageHandlers. </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.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COI guess that we are speaking about 2 different kinds of message buses: buses with lots of message types and buses with few message types, but general ones (your analogy with envelope) - no data exposed, but in order to extract this data, the class that knows how to do extract it needs to use ugly instanceof, casts etc; some solution to the instanceof problem is Visitor pattern, but with it we get back to one big class which knows about all types of messages (you have to add all visitXXXX methods to the Visitor) So with event bus you have either to use instanceof or big listener classes. Bad
      singulars
    2. COAs for your analogy with ball, that 'the players don't react until they see the ball' - the same is true for event bus: all players must see event bus in order to communicate. Every nontrivial application has thousands or millions of objects in memory. How many people can play football - typically it's 11, but I think that even this is too many. Can you image 1000 people playing football at the same time in the same football field? That would be quite interesting :-)
      singulars
    3. CO@iirekm, In the code base I use, the global event looks like this MessageEvent event = new MessageEvent("EventId",oldValue, newValue). The actual constuctore def: MessageEvent(String id,IAdapter oldValue, IAdapter newValue). So to extract the new value all i need to do is MyObject value = event.getNewValue(MyObject.class). No big listener!
      singulars
 

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