I'm in the process of extending and improving a website that has quite a few structural problems. It looks very much like the developers before me had heard of MVC but didn't understand the ideas of abstraction or modularity. So the MVC "framework" is a) bespoke b) broken c) patched and d) there are several in use all at once. I intend to fix that.
This is not the first time I've re-built a site's framework, BTW, but it is the first time I've had to fix an MVC framework. However, I'm coming up against some missing holes in the MVC knowledge here on SO.
The first is how closely programmers seem to tie their SQL database with their models. This doesn't make sense to me: do programmers normally have the model looking after the data abstraction? (To me this is little better than putting SQL in raw PHP code.) Or is there a data access layer normally employed that "Does SQL"? I know from experience that the latter means the calling code doesn't have to worry about where the data is, or how to get it or how to write it: the API handles that.
But what about the Models? Are they intended to be re-usable amongst different pages? Should they care about just where the data is stored? Shouldn't they be more concerned with handling the logic between data-fetch and data-show (e.g. turning a contact's group ID into a displayable name)? And data-save and data-write (e.g. figuring out how to turn $_POST values into savable data)?
Maybe the MVC model really be DMVC - Data-Model-View-Controller.
Lastly, although this is from a PHP point-of-view, how well do these concepts translate to a JSP site?
posted date: 2008-12-08 16:55:00