I have a Server application with a GUI. Written in c#.
Now I want to use the MVC pattern for the whole Application.
Normally you have 1 Model, 1 Controller and maybe n views. Okay, I have one of everything, but I’m not sure with the Model.
My Situation:
There are 1 server state, that can be online / offline, that has a client count, etc.
This could be my “ServerModel”. I will handle the network connection through my network library and create student object if one is connected. That all happens here.
The view will be noticed if there is a new student and display a GUI element for the new student (through the controller). Now there is a action related to a special student in my view and the controller get notices “StudentChanged” and get the student that has changed.
The Question:
The controller can now change the student directly OR tell the ServerModel how to change the student.
The 2nd method seems to be overdone on the first look, but keeps the MVC design clear.
I would like to change the student directly from the controller. But I’m not sure if this violation of the MVC (student is not a model but part of a model) brings any drawbacks in later development or the flexibility of the whole code.
Greeting from Hamburg 😉
The Controller should collect the information that the user wants to change about the student and hand it off to the View.
You may want to look at using the command pattern to bundle the actions needed to change the student.
For example
user wants to change the student via
an interface.
CommandObject
Student UI. When the user is done
the command retrieves the information.
closes the ChangeStudent UI.
done.
done.