railsconf2011: Fat model aren’t enough

Jeff Casimir talked about skinny controllers, fat models and beyond. His first statement was that it was a best practices talk but he did not like that title. Best is not a good word. It should be ‘a practice’ as there are others that are just as valid. Going from there the basic idea of skinny controllers and fat models was explained. That is just for the back-end of the app, what about the front-end? That is an issue, while we should make it look like a bento box we mostly shove all the crap over there. Stating that views should actually just be HTML with some data.

Jeff had several ideas on how to make views more beautiful!

Presenters

The presenter pattern is not a pattern from the book, it’s one that can be found on wikipedia. A presenter is a decorator, not just on one object but on many. Therefore it is more like a shepherd to herd to object to do what you want. Jeff proposed to create a presenter in app/presenters/X. Just like John and Bruce yesterday he put in a good point on how to do view classes. Again, objects are not scary!

DRY

DRY in Jeff’s talk was not don’t copy past. It is do not repeat the same idea twice. To do this it needs to be pushed down into the model, not a helper file… DRY can also be keeping things simple, separation of concerns and keeping your methods smaller then 8 lines (he said another guru said that 8 should have been 6). Refactoring was also mentioned… too many thing you could do here to put in a combined blog post.

Scopes

Scopes were good, they are readability, you can chain them and all this other fancy stuff. Problem is that in Rails3 scopes are kinda dead. At a point they were even deprecated, no lambda, proc… But after some hate they got reverted. Why should it be deprecated? Well with the Rails3 implementation of DB requests their not really useful anymore. Lambda are actually hard to remember and hard to read. While with the Rails3 stack you can just write a method that does exactly the same but a lot nicer… That should be good enough for now!

Embrace ruby

A lot of us started out with Rails, and then got into a bit of Ruby to be able to write in Rails. Jeff finds that sometimes Rails developers do not embrace Ruby enough and we try to solve Ruby issues with Rails. We should learn more about Ruby and he suggested a couple of books to do so:

Extra

During the questions area a interesting point was made. There is no real BOOM project. No project you could show to a non-tech person and see their direct reaction. There is no project one could just install like PHPBB, Mambo/Joomla. Jeff said: “I’m gonna do that this summer”.

The big question still is: Why do we not have such a consumer project?

, ,

  1. Leave a comment

Leave a comment