5 ms·
To answer your question in the title...MVC is a good solution. The way frameworks implement it also varies, but basically the idea is to setup a way to separat
by mrtron 19y ago
To answer your question in the title...MVC is a good solution. The way frameworks implement it also varies, but basically the idea is to setup a way to separate things into a few layers. I have found MVC-based systems easiest to implement and modify because of this separation.
Caveat: My MVC experiences have been mostly with Java (Struts) and Python (Django)
Then to get into your actual points:
1) The view CAN do the work of determining what will be shown. To quote the Django site: "In our interpretation of MVC, the "view" describes the data that gets presented to the user. It's not necessarily how the data looks, but which data is presented."
2) Anything that is a common widget should be abstracted and included on the page in some sort of "include". Either have some sort of base page that does the work, or on the individual pages do some method of "include". This really doesn't relate to MVC, other than your point about adding the data to your context/session, which should again be done generically and non per-page.
3) The general idea for any MVC system is to have the flow go through one controller. This controller may delegate to sub-controllers, but the idea is everything goes to one spot.
4) What is the best solution? There are many good solutions for writing a web app.
- jamiequint 19y ago"The view CAN do the work of determining what will be shown" 1) In Django the controller is called the view and the view is called the template, same principle but unless you want to get confused you should think of it as MTV == MVC (if you want to equate the two, Django seems to be perfectly happy making up its own interpretation of MVC for no apparent reason). Really the controller (in the MVC sense) is doing the work here.
- mrtron 19y agoSorry I think its just the wording that is confusing here. The controller is doing the work to determine what will be shown, yes. I meant once the controller determines which view should be used, the view then can manage the specific data being shown. Django does separate the view into a 'view' and a 'template'. One does your work, and the other does the displaying.