Am I right in this assumption or should it be the Controller's job to setup the DBConnection and then pass the acquired reference to the model which uses it?
that controller shouldn't do anything material in MVC
The Controller is the one who is responsible for making the views show, and keeping track of all the views that are currently open, and when they close...
, and when the data changes on them, and when to make the data change.
-- notifies all registered views about the change in the model state
View:
-- receives a notification from the Model
That means that if I see something like the following in the controller ...
myGUI.myComboBox.setSelected(1);
myGUI.myTableModel.setModel(tableModel);
myGUI.myConnectionPanel.myRadioNetworkConnection.setSelected(true);
... I get very upset.
I still say it is the controller that gets notified of any changes and lets the other know that it has.
If you are collecting origin, destination and title information for one model update event how are you pushing all that information at once to the view?
If you are encapsulating it in a class that gets pushed and then the view calls getter methods on that class isn't this equivalent to just calling getter methods directly on the model in which case only a 'pull' is required.
So when you add a button to the View, something else has to change to make that button do something.
If the button is to get data, is it the responsibility of the model to know that the button was pressed and to get the data and to update the view?
Now I can say that this action can be in the controller or outside, that doesn't matter, because in each case one of those two classes has to change with the change of the view.
OK, but let's consider another example. Say you rename one of your GUI components, or move it from one panel to another, or replace it with something else. Now, since your controller refers to your GUI controls explicitely, it will need to change, too. But in the design that I advocate, nothing will need to change beyond the view itself.
It is the reponsibility of the model to notify the views about the change in data, and it is controller's responsibility to know that the button was pressed.
So then you are saying that here the model has a reference to the view also? That sounds like more coupling.
Now isn't that two scenarios. Where was the third? I am missing that one.
I don't even know how to spell CIA. But this tiny ad does:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|