Search code examples
phpmodel-view-controllercodeignitercode-organization

MVC: Lots of small models or a couple of big models?


I am in the process of writing and organizing my unfinished application in codeigniter and I am just wondering weather it is better to have lots of small models, so your only loading what you need when you need it; or making a couple of big models so it just loads all functions even though you only need one of them?

Any help would be appreciated. Thanks.


Solution

  • From a performance point of view it is better to only have a couple of big models(files). I believe that is one of the main reasons why Cakephp used(not keeping track of it) to be very slow. Just have a look at the dependencies Cakephp had.

    But from a design point of view it is better to have a lot of small models because of the SOLID principles. For example an object should have only a single responsibility.

    But then again when you are moving to production, I think you should combine all the php files to a couple of single files to have lesser require(I/O) statements. I/O is a performance killer.