Don't ask to ask, just ask | |
PerlMonks |
Re: Implementing Model-View-Controllerby Joost (Canon) |
on Jan 04, 2006 at 14:53 UTC ( [id://520928]=note: print w/replies, xml ) | Need Help?? |
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? Yes and no. For your example, you'll probably want 3 objects:
update: Note that in this design, there is no User object outside the 3 XXX::User objects. One thing to note is that although in typical CRUD applications, like those used to demonstrate ruby on rails, there are is a single model, a single controller and multiple views for each database table, this is not the best way to design all applications. The seperation between model, view and controller is a good one, but you might want to encapsulate more than one database table into a single model class and/or use views and controllers that span multiple model classes. I suggest you try building a few small apllications using one or more of the available MVC frameworks to get a good feel for what works well. Most frameworks suggest a basic structure for your application on which you can build, and building everything from scratch will probably get you distracted by low-level details and it'll take a lot longer too. Update2: you might want to check out my article, the MVC pattern in web applications - it specifically explains the roles that the M, V and C parts play and how they interact.
In Section
Seekers of Perl Wisdom
|
|