I'm trying to figure out the correct layout of classes, methods, files and folders for a MVC design based system.
Let say we have a Page. Page is a simple page with title, text and a sub menu. And it can also include a gallery (which would be a separate object both in the database and in the code).
I would have a
PageDAO
class that would have all database related functions (it would extend mainDAO
class, that would hold generic DB functionality as select, save, delete etc)I would have separate Page class that would define variables and non-db related functions for this object
I would have the MVC itself where
PageModel
would construct pageDAO
class and page class and build content that would then be processed in controller and prepared for a viewGallery would be defined in a separate class outside MVC (let say libs folder) and it would never be used as a view ( I mean, I would never call the gallery page itself). Page model would create Gallery class and controller would place it in a page view
Menu class/function would be more generic function (as it would work for both pages and categories, if the code is used for e.g. shopping site) and would also be defined in a separate area (could be libs folder again). Menu setup based in that functionality would be called in model
The above means I would have the following structure
model, view, controller files and folders based on standard MVC approach
dao lib folder for all
DAO
classeslib folder for classes like
Page
,Menu
,Gallery
Does it look fair to you? I'm just anxious not to spread out the code over too much classes as it then means more 'includes' and more object calls. But perhaps that's the way to go? So far I haven't been using much MVC approach and been keeping files rather compacted. Want to get to know about the best practices