Mediator or too much responsibility

In my application, I have several components that should know about each other, such as the menu bar and toolbar, which should know about the table to add or remove tasks, as well as to determine which task is selected.

So, I created an object with a name guiMediatorthat I pass to each object, and they register with it so that they can reach each other using this object. He is also responsible for triggering events when new jobs are added or background workers finish work.

Since he knows a lot about the system, is this type of use too much responsibility in one place or is it the correct use of the template?

+3
source share
3 answers

Normally I would use a command template for something like this:

  • The user clicks the "Foo" button on the menu bar, which executes the FooButtonClickedCommand.
  • FooButtonClickedCommand does everything it needs to do, and then changes the view accordingly (menu bar, tables, etc.).

Thus, your teams are aware of all the components of your view, but the only thing your viewing components need to know is which command to execute when this action is performed by the user.

+3
source

I would use a passive view, which you can read here here .

  • , , Setup, Entry, Display .. . .
  • , , , UI.
  • UIObject ,
  • Command , .
  • UIObjects .

, , .. .

. , , , , , , .

, . . , . .

+1

, ... , ;)

-3

Source: https://habr.com/ru/post/1708645/


All Articles