title: Fat models, skinny controllers and the MVC design pattern
body: <p>I just read a <a href="http://teknoid.wordpress.com/2009/01/06/another-way-to-think-about-mvc/" rel="noreferrer">blog post</a> that explains MVC with a banking analogy. I have a few months of experience with web application development with an MVC framework (CakePHP), so I get the basics, but I began to see a theme that made me think I'm taking a flawed approach to where I put my logic:</p>
  
  <ul>
  <li>Fat models, skinny controllers</li>
  <li>Keep as much business logic in the models as possible</li>
  </ul>
  
  <p>In my app, models are anorexic and controllers are obese. I have all business logic in the controllers and nothing besides associations and validation rules in the models.</p>
  
  <p>Scanning through my controllers, I can now identify a lot of logic that should probably go in a model:</p>
  
  <ul>
  <li>The app has lists, which contain items, and the items can be ranked. The sorting logic which puts the list in ranked order is in a controller.</li>
  <li>Similarly, items (Item model) also have images (Image model). Each item may have a default image (designated by image_id in the items table). When an item is displayed with its images, the default image should appear first. I have the logic that does this in a controller.</li>
  <li>When a list is displayed, related lists are displayed in the sidebar. The logic to determine which lists are related is in a controller.</li>
  </ul>
  
  <p>Now to my questions:</p>
  
  <ol>
  <li>With the examples I gave above, am I on the right track in thinking that those are instances of logic presently in a controller that belongs in a model?</li>
  <li>What are some other areas of logic, common to web apps, that should go into models?</li>
  <li>I'm sure identifying this problem and changing my design pattern is half the battle, but even if I decide to take those examples I gave above and try to move that logic to a model, I wouldn't know where to begin. Can anyone point me in the right direction by posting some code here, or linking to some good learning resources? CakePHP specific help would be great, but I'm sure anything MVC will suffice.</li>
  </ol>