I have a MessageHandler class which receives and validates messages before determining which components in the architecture they should be delegated to so they can be processed. This involves calling functions with different names and possibly different signatures on classes in different components.
What is the best way to implement the delegation?
The diagram below shows two possible approaches.
Option 1 - each component that must process messages exposes an interface, which is realised by a Facade. For each message, the MessageHandler calls the appropriate operation on the interface and the facade delegates it to the appropriate class internally.
Option 2 - for each message, the MessageHandler calls the appropriate operation directly in the relevant component.
Weighing up the advantages/disadvantages of each:
Option 2 means polluting the message handler with a handle of each class in every component that will process a message. It also makes it harder to test the message handler in isolation. Doesn't seem right.
Option 1 - seems like a better approach. The message handler depends on an interface rather than concrete classes, which also makes it easier to test.
I'm wondering if option 1 a good approach? Or is there a better way to achieve what I want?