Re: generic MVC question



Paul Davis <pbd op net> writes:

> [ i'm not sure where else to discuss this. if anyone has some
>   ideas on good MVC forums, let me know. thx. --p ]
> 
> suppose you have a combined View+Controller.
> 
> you use the Controller to attempt to change the Model. this usage
> changes the appearance of the View. the attempt to change the Model
> fails for some reason (e.g. an illegal value).
> 
> what causes the View to be reset to the correct state? 
> 
> i ask because in a genuine MVC model, you never update the View based
> on the return value of a modifier function - the View is updated when
> notified of a change in the Model. in this case, there is no change in
> the Model, but the View is "stale" because it was modified to reflect
> what was happening in the Controller.
> 
> if you combine View+Controller, do you have to always check for result
> of a Model modifier function, and reset the View if the function
> failed? or is there some better paradigm for this that i'm not seeing.

Well, if possible, you simply don't change the visual appearance
of the view/controller until you get notification back from
the model.

That is, if your view/controller is a "scrollbar", you try to update the
model when the thumb is dragged, but don't actually display it
in the new location until you get notification back from the
model.

This doesn't always work if your view/controller is an existing
control that has an "internal model" - say a GtkCheckButton. In that
case, you probably have to take the approach of:

 - Try to update the model
 - Refresh the state of the VC from the new model state.

Regards,
                                        Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]