1

I'm creating the architecture for a new embedded project. The system has some inputs that go to wildly different outputs. The whiteboard pattern is very useful for this (see Listeners Considered Harmful: The "Whiteboard" Pattern), as it decouples the input component from the output components (a 1-to-N relationship).

However, I'm struggling with the N-to-1 relationship (where one output gets data from wildly different inputs). Should I use the whiteboard pattern there? And what about the 1-to-1 relationship?

Advantages that I see of the whiteboard pattern:

  • separate deployment and testing of sources and listeners.
  • the whiteboard (EventAdmin in the OSGi world) can be monitored separately.
  • there is no build-time dependency.

Disadvantages that I see:

  • there is no compile-time check on the events (if someone makes a typo in the event topic or the data, you're screwed).
  • overhead of the whiteboard (I've done measurements, and it's significant on our platform).

I'm not quite sure how to balance these trade-offs.

1

After discussing this with a colleague, and some more thought, I came to the conclusion that it depends on the nature of the dependency.

The whiteboard pattern completely decouples sources and listeners. The overhead (in processing time and absence of compiler checks) is warranted if:

  • the listeners of an event are completely unrelated to the source (i.e. in another part of the system)
  • sources and listeners should have the ability to be restarted separately
  • either the source or the listener is created by another company (as strings are easier to exchange than objects)

Note that none of these criteria mention how many N there are in the relationship.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.