In my application, I have several components that have to know about each other, such as a menu bar and a tool bar that both need to know about the table to add or remove jobs and also to find out which job is selected.
So, I created a object called guiMediator that I pass to every object and they register themselves with it so that they can reach each other using that object. It is also responsible to fire events when new jobs are added or background workers finish their job.
Since it knows a lot about the system, is this type of usage too much responsibility in one place, or is this the correct usage of the pattern?
Normally I would use the command pattern for something like that:
So your commands know about all your view components, but the only thing your view components need to know is which command to execute when a given action is done by the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With