I am writing a Java Swing application in MVP style. The model works on various calculations in a different thread that are not relevant for this question. When these updates occur, I call EventQueue.invokeLater
to update the GUI. Should these thread-switching calls occur in the Presenter or in the View?
Argument for Presenter:
- The view should be as dumb as possible
- If the view does it, it's theoretically possible for the view to call
EventQueue.invokeLater
from the EDT, which is wasted work
Argument for View:
- It is not necessary to have a dependency injected
Executor
for unit testing the Presenter - The View is responsible for rendering itself, ensuring that updates happen on the EDT is part of that responsibility
I'm not certain. What's the best practice?