Best MVC practice

#1
[eluser]snoo[/eluser]
Hi Guys,

I'm new to the whole MVC structure and to coding in general. I'm a little confused and would like to know the best practice on where to keep my code so that it is clean and easy to maintain.

So far with CI, this is what I've been doing.

View: html and printing variables passed from controller.

Controller: controls what data to show / action to take base on user action

Model: retrieve data from database and send it to controller.

Because of my current practice, my model is usually pretty slim, consist of standard CRUD functions and variations of it. On the other hand, my controller is usually fat and bulky due to having to parse inputs and segments and assemble arrays and variables so view can easily print out without having to do much php init.

Is this normal, or should I use model to do some of the logic work I'm currently doing on controller?

Thanks for any input.

William

#2
[eluser]TWP Marketing[/eluser]
It may not be "pure" MVC, but I use my model(s) for massaging data after retrieval from the db. This keeps my controller code leaner and helps me to understand my own code after some time has passed. I also use model methods to construct data arrays and read configuration values (which I consider part of my 'database').


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.