Hi all,
Just wondering what you views are on where to place certain dialog boxes with a
typical MVC setup
A View, A Model, A Controllor
The model holds the data.
The controllor is only thing allowed to manipulate the model.
The view displays the model.
The view may have gui_models that wrap the real model so columns
in tables can get reordered but it cant touch the real model except
throught the controllor.
A button in the view labelled "Do something"
On click the view calls the controllor.doSomething()
Once the controllor has done its stuff manipulating the model
perhaps calls view->refresh()
Or perhaps the model tells an event manager "I've changed"
and the event manager tells the view->refresh()
Now thats all pretty straight forward.
What I have trouble deciding where to put is some dialog boxes
that interact with the user.
For example the "You have unsaved changes, do you wish to save ?"
type dialog.
You click the top right X, or choose exit or whatever.
Choice 1: dumb view
The view will have to tell the controllor "user requests exit"
The controllor must check if there are unsaved changes
if so the controllor must request the view->askUserToSave()
And depending on the answer, save the changes before exiting or not.
Choice 2: Intelligent view
The view checks to see if there are unsaved changes
If so it prompts the user "do you wish to save"
And then calls controllor->saveChanges(), controllor->exit()
or just controllor->exit()
Thanks for any comments
RC - 20 Jan 2005 21:52 GMT
I would do it in the View. Here is why:
The View is an encapsulation of user interface, which can change. For
example, you might have to use bigger font on all GUI screens to help older
people. Or you might have some I18N needs. Since this dialog is definitely a
part of GUI, View me be appropriate.
Another reason is more practical, you might need a modal dialog, so you need
the reference to the original frame that might be hidden in your view class.
You do not want that to be exposed to the controller, so that you expose
your internal implementation.
That being said, for more complex (sub) GUI (like a wizard), you might call
back the controller to make sure your View wouldn't end up becoming a
controller on its own.
This is my personal opinion, and certainly not all will agree.
> Hi all,
>
[quoted text clipped - 39 lines]
>
> Thanks for any comments