Thoughts on technology, recreation, society, etc

May 17, 2011

RailsConf 2011: Fat Models Aren't Enough

Listening to Jeff Casimir from JumpstartLabs at RailsConf 2011 talking about practices in Rails, skinny controllers and fat models.

Jamis Buck started the idea of fat models. Originally when rails was getting going tons of stuff was going into the views, then folks started stuffing everything into the controller. 80-100 line methods. The call to action was to move logic down into the model with well described method names.

Beautiful views are HTML. Views should be data access, a little bit of looping.

Controller actions should be 8 lines.

Most of the logic should go into the model. But fat models aren't enough. A model should be like a bento box, little pieces of art, structured division. The model layer is where we get to do real programming. But models don't have to get totally stuffed full of junk.

Let's look at the presenter and presenter pattern. The formal definition of a presenter is a decorator, takes in an object and adds some new options. Jeff likes to think of a presenter as more than just adding a new option or two but to add significant simplification to the app.

Helpers are stupid, a big mess.

[I'm going to have to grab the slides from this, a lot of good food for thought and practical advice.]