Re: Design Question for Model and View
Jason Cavett <email@example.com> writes:
The problem I run into (sort of a problem - I can easily hack around
it, but I'm wondering if there's a better way) is that it can be tough
getting information from the user when I need to accomplish a goal.
For example, a model operation might need a yes/no-information.
According to MVC, the model then would change a variable
?information_required? to be ?true?. The View would be
subscribed to this as an observer and, thus, become notified
of the need. The view will create a yes/no-requester visible
to the user.
When the user decides to supply the information, the
controller will tell the model, which then will set
?information_required? to ?false?, which will make the view to
close the requester.
the model notifies that view
The model must not know that there is a view, otherwise it
would be coupled to the view in a way that is not intended in
It only knows that there are observers, so it ... (see above)
The view sets a flag in the main model notifying that it should
In MVC, this would be the part of the ?controller?.
But then, maybe you did not want to use MVC at all.
Is this a good way to go about it?
I can not determine, whether a strict and pure application
of MVC is advantageous in your case. I just wrote /how/ to
do it /if/ one wanted to do this.
Things might be simplified by a kind of ?hierarchical MVC?,
where the confirmation-logic is contained entirely in the View
of the outer MVC, while it consists of an internal MVC