I think you're pretty much on the go. To answer your questions one by one:
1. Should I keep the state in the model? Yes, you can and should save the state in your model - the model is a state and behavior that changes this state.
2. Am I correctly allowing the controller to display OptionPane? yes - the application design (logical stream) decides where the file comes from - the models, of course, no matter how the file name is received for reading, just so that it gets the file name. the stream is the domain of the controller.
3. should the model read the file? yes again, reading the file is part of the model. Although the controller calls the swing worker, the swing worker is conceptually part of the model, at least the basic logic performed by the swing worker. Ideally, the entire logic of file loading lives in model classes. Then the controller can arrange for this call using a working swing. A controller is one who decides that the file should be downloaded in the background thread and instructs the model to download the file from the background. The controller dispatcher worker receives download execution events from the model and processes them by calling publish (), and then process () updates the user interface.
Basically, you should be able to rewrite the entire application as a console application without changing the model. Naturally, the view is changing, but it is because now it must present the model using stdout, not Swing. The biggest changes occur in the controller - the application stream will be different (the file selection comes from the program arguments), the controller no longer listens for button presses for the direct stream, but has a fixed stream or interacts with the user via stdin. And the thread model in the controller is different - no need to worry about EDT, so there is no need for a swing.
So, you see that the model takes care of the state and changes of this state, the view takes care of the state representation, and the controller does the rest, in particular, connecting the model to the view.
source share