Does the reseller template work in this situation?

So, for my current project, there are three main Java classes:

  • GUI
  • Instant messaging
  • Calculation

Essentially, there should be a complete connection, so we decided to use the intermediary approach, rather than letting the graphical interface run the entire project.

Basically, the pick is going to encapsulate the message. The problem we are facing is how to allow updating GUI components without creating tons of methods to call the broker at any time.

Ex. Say the GUI wants to log into the userโ€™s system, the process of creating the stream and logging in goes through the intermediary, but then the intermediary must pass the success / failure back to the graphical user interface and update the status message.

Another problem is that you need to update the GUI, but not the moderator. Is it practical to just let the GUI instantiate this class and run it, or should everything go through an intermediary?

Our original design simply had a GUI that controlled everything, but it really killed reuse. Is there a better design method in this case?

+3
source share
3 answers

, Observer , . , . , . -, , Command. Ruby, , . Java, .

+3

, callback/notification , , .

, Java. , , , Java, , , kmorris.

0

, , , ( Command). GUI .

, , . , , GUI- :

   gui.a()
   gui.b()
   gui.c()

you can create a single method that processes the result of calling all three. The advantage of semantically grouped methods (i.e., setFileInformationover setFileMenu, setTabetc.) Also then, if you need to change the GUI, the contents of the methods may change, but the call that the intermediary makes may not.

0
source

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


All Articles