W
W
wolf-98302015-07-19 11:32:36
Java
wolf-9830, 2015-07-19 11:32:36

How to effectively communicate between classes?

Let's say I have a button class that gets all the paths to files in a folder and sorts them, and another button displays the file names. In the class with the first button, I have declared an ArrayList with file paths, how can I transfer this ArrayList but the second button class?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Gamega, 2015-07-19
@gadfi

a button class that sorts something, another button class displays something ..... if it is effective, then rewrite this horror.
A button is a button, it does not have to do all this, you can hang a listener on it and catch the event, but do something about this event.
Logic and ui should be as loosely coupled as possible.

�
âš¡ Kotobotov âš¡, 2015-07-19
@angrySCV

according to the classic user interface (buttons) -> do nothing, they only generate events, which are then processed by various kinds of workers (which sort or something else), and return the result somewhere.
this model has proved its effectiveness and is widely used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question