V
VisionSet
More MVC stuff.
In a View you may do this:
class View {
Model model;
View() {
model = Model.getInstance();
setupGUI();
}
}
Now my model when instantiated goes off and deserialises a bunch of stuff
and all this stuff fires events at the view to notify its initial values.
But the view hasn't set up its GUI at this point so fails to be initialised
correctly.
Another approach would be to set up the GUI and then ask the model for its
intial values, but this duplicates the way widget models are updated.
Another approach would be to explicitly request the model to notify all
listeners/observers of its complete state on demand.
Another approach would to instantiate the model as the LAST thing I do
How is it best to handle the initialisation of the GUI?
[The getInstance() approach... The 1st view to be instantiated will cause
the model to be instantiated, future views will get this same instance.
With that in mind, perhaps it is pointless to fire events at time of Model
instantiation, only the 1st view will receive the events, highlighting the
requirement that perhaps the views should poll the model for initial
update?]
In a View you may do this:
class View {
Model model;
View() {
model = Model.getInstance();
setupGUI();
}
}
Now my model when instantiated goes off and deserialises a bunch of stuff
and all this stuff fires events at the view to notify its initial values.
But the view hasn't set up its GUI at this point so fails to be initialised
correctly.
Another approach would be to set up the GUI and then ask the model for its
intial values, but this duplicates the way widget models are updated.
Another approach would be to explicitly request the model to notify all
listeners/observers of its complete state on demand.
Another approach would to instantiate the model as the LAST thing I do
How is it best to handle the initialisation of the GUI?
[The getInstance() approach... The 1st view to be instantiated will cause
the model to be instantiated, future views will get this same instance.
With that in mind, perhaps it is pointless to fire events at time of Model
instantiation, only the 1st view will receive the events, highlighting the
requirement that perhaps the views should poll the model for initial
update?]