Hello,
I have a basic question regarding the implementation of an MVC-framework to a website.
I currently have a very basic site which i try to implement an MVC-framework on. I use a frontcontroller to redirect the requested pages, and for each page (=view) i have a separate controller.
So let’s say my sitemap is:
- Profile (this is a view)
- News (this also)
- Help (this also)
Then, besides the frontcontroller i also have 3 pagecontrollers, each for it’s corresponding view/page.
But let’s say each of the views interacts with a database, for example, the view ‘profile’ displays the users stored information (retrieve from database), while the view ‘news’ stores information inputted by user, into a database (insert into database).
Now, should i also have one model for each controller/view ?? Or should i have 1 model which contains all the classes (for retrieving and inserting all kinds of data)? Or should i split my model in 2 models, one with all the classes for retrieve commands, while the other model for Insert commands???
The reason i ask this is because currently, i have one model for each controller/view, so for example: for ‘Profile’, i have:
-profileView
-profileController
-profileModel
and for News i have:
-newsView
-newsController
-newsModel
etc. etc.
Each element has it’s own view, controller AND model. Now when retrieving information from the database via a model, i found myself writing the same code for some models, since sometimes information has to be presented on different pages. Now if multiple models have almost the exact same pieces of code, the that wouldn’t be that efficient right?
So hence my above question 😊.
Much much thanks in advance!