|No such thing as a small change|
Implementing Model-View-Controllerby ghferrari (Acolyte)
|on Jan 04, 2006 at 12:57 UTC||Need Help??|
ghferrari has asked for the
wisdom of the Perl Monks concerning the following question:
While there are plenty of web articles on the theory of the model-view-controller design pattern, there is precious little advice available on how to implement it, in terms of structuring one's classes and objects.
So let me ask a simple question. Suppose I'm writing an application that looks up user information in a database, performs some calculations, and then outputs that information. Suppose also that for the sake of code encapsulation, I want to use object-orientation, and wrap up my code in a "user" object.
So, the practical question is this. Does it follow from the MVC design pattern that I ought to have both a Model::User object and a View::User object, and perhaps a Controller::User object, too? In short, won't I need a separate "User" object for the model, the view, and maybe the controller?
If that's so, then true, it means I can update any member of the MVC triad separately. But it also means that I must update each member separately, even if I want to make the same update to each. And mightn't that be more hassle than it's worth?
Perhaps I just lack a good idea of how to implement MVC. If anyone has any links to articles on the implementation (as opposed to merely the theory) of MVC I'd be really grateful for them.GHF