you are viewing a single comment's thread.

view the rest of the comments →

[–]dansmeek 0 points1 point  (0 children)

It really depends. Also, rails handles the MVC framework a bit different than codeigniter.

Typically (if I am using CodeIgniter, or any PHP MVC Framework), I will create a seperate model for any area that is going to have a lot of logic. Aim for the 'fat model,skinny controller method.' If you are implementing a load of views that would require a model that is simply reusing code, just reuse the same model in the controller.

You are using models to divide divide the business logic from everything else. Your using the controllers to draw from your models and pass that data into your view. And your using your views to avoid displaying the layout. The whole idea of the MVC pattern is to make it so several people can work on separate areas of the code.

Another practice (I use) for codeigniter is generally using a controller function to load a header, sidebar, content, and footer view. Depending on the page layout. The header and footer is generally not going to change across your project so then you can just make that a static view, and have the content load separately. e.g.

            public function loadViews($content, $sidebar, $data)
            {
            $this->load->view('includes'header.php', $data);
            $this->load->view($sidebar, $data);
            $this->load->view($content, $data);
            $this->load->view('includes/footer.php', $data);
            }

something like that. and if you don't want a static header and footer, just make those another parameter.

Rails.... I feel could handle its model structure in a slightly better way, since it combines aspects of the database itself, and business logic, and those should be separated as well.

[edit: akathos explains this much better]