This is a discussion on Model View Controller within the Software Patterns forums, part of the Testing category; Hello everyone, I am coding a system which I am trying to base on the MOdel View Controller Pattern. I ...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Model View Controller
Hello everyone,
I am coding a system which I am trying to base on the MOdel View Controller Pattern. I have my model sorted out but I am not trying to asertain what is the view and what is the controller. Example: There are two ways to create me model, through a user interface or through loading up a configuration or settings file using XML. To me these seem like controllers, creating and altering the model. However I also want to be able to save my UI changes as to the XML file, as well as see my changes on screen. So these are two views, a XML view and a UI view. However waht I am worried abaout is that I have identified the view and controller incorrectly. Also the loading and saving of the XML should be to the same format and I am worried that by changing the load controller, it would be very easy to foget the "Save" controller. Peoples ideas and opionion on my apprach will be really welcome. Thankyou Philip |
|
|||
|
Re: Model View Controller
Philip Poole wrote:
> Hello everyone, > > I am coding a system which I am trying to base on the MOdel View Controller > Pattern. I have my model sorted out but I am not trying to asertain what is > the view and what is the controller. > > Example: There are two ways to create me model, through a user interface or > through loading up a configuration or settings file using XML. To me these > seem like controllers, creating and altering the model. > > However I also want to be able to save my UI changes as to the XML file, as > well as see my changes on screen. So these are two views, a XML view and a > UI view. > > However waht I am worried abaout is that I have identified the view and > controller incorrectly. Also the loading and saving of the XML should be to > the same format and I am worried that by changing the load controller, it > would be very easy to foget the "Save" controller. > > Peoples ideas and opionion on my apprach will be really welcome. IMHO, a simple rule of thumb can be: 1. Think about several versions of the same application, with different user interfaces and even non interactive (command-line) versions. 2. The model is the common parts to all versions (interactive and non-interactive) 3. The user interface (UI) of an interactive version join together the view and the controller (or several simultaneous views and controllers). 4. The view is the part of the UI that includes all the necessary elements to refresh or redraw the UI after some change in the model. It could be implemented simply as a single global redraw function or as several partial redraw functions. The view should call the model to get the updated data. 5. The controller is the remaining part of the UI that is not the view. Its job is to take input from the user or from external sources and call the appropriate functions of the model. 6. The model, view and controller have to be synchronized to maintain the view up-to-date. There are quite different ways of doing it: 6.a The controller can call the view after calling the model. 6.b The model can call the view after changing itself. 6.c A 'notifier' pattern can be used to receive 'register' request from views and 'change' notifications from the model, and then call the registered views. 6.d The view can poll the model frequently and refresh itself. 6.x Etc. etc. ... -- To reply by e-mail, please remove the extra dot in the given address: m.collado -> mcollado |
|
|||
|
Re: Model View Controller
Thankyou very mcuh for your help
Philip "Manuel Collado" <m.collado@lml.ls.fi.upm.es> wrote in message news:41e7f6c9@news.upm.es... > Philip Poole wrote: > > > Hello everyone, > > > > I am coding a system which I am trying to base on the MOdel View Controller > > Pattern. I have my model sorted out but I am not trying to asertain what is > > the view and what is the controller. > > > > Example: There are two ways to create me model, through a user interface or > > through loading up a configuration or settings file using XML. To me these > > seem like controllers, creating and altering the model. > > > > However I also want to be able to save my UI changes as to the XML file, as > > well as see my changes on screen. So these are two views, a XML view and a > > UI view. > > > > However waht I am worried abaout is that I have identified the view and > > controller incorrectly. Also the loading and saving of the XML should be to > > the same format and I am worried that by changing the load controller, it > > would be very easy to foget the "Save" controller. > > > > Peoples ideas and opionion on my apprach will be really welcome. > > IMHO, a simple rule of thumb can be: > > 1. Think about several versions of the same application, with different > user interfaces and even non interactive (command-line) versions. > > 2. The model is the common parts to all versions (interactive and > non-interactive) > > 3. The user interface (UI) of an interactive version join together the > view and the controller (or several simultaneous views and controllers). > > 4. The view is the part of the UI that includes all the necessary > elements to refresh or redraw the UI after some change in the model. It > could be implemented simply as a single global redraw function or as > several partial redraw functions. The view should call the model to get > the updated data. > > 5. The controller is the remaining part of the UI that is not the view. > Its job is to take input from the user or from external sources and call > the appropriate functions of the model. > > 6. The model, view and controller have to be synchronized to maintain > the view up-to-date. There are quite different ways of doing it: > > 6.a The controller can call the view after calling the model. > > 6.b The model can call the view after changing itself. > > 6.c A 'notifier' pattern can be used to receive 'register' request from > views and 'change' notifications from the model, and then call the > registered views. > > 6.d The view can poll the model frequently and refresh itself. > > 6.x Etc. etc. ... > -- > To reply by e-mail, please remove the extra dot > in the given address: m.collado -> mcollado > |