Monday, March 7, 2011

Crafting Rails Applications Review

Jose Valim is well known in the Rails community for writing a lot of code and being on the Rails core team. He's also to blame for Inherited Resources a plugin that I've seen be more horribly misused than any other. He's one of the most qualified people you could get talking about some of the more advanced tricks that are present in Rails these days and Crafting Rails Applications really does cover a lot of ground in intimate detail.

Crafting Rails Applications: Expert Practices for Everyday Rails Development

Crafting Rails Applications is a tough book to review, there's a lot of really good information in it that can't be found anywhere else short of reading through the Rails source and trying to work out what's happening. But, anyone who really is going to get a lot out of the book is going to end up reading a lot of the source anyway. A good deal of the information in it will be of more use to people creating plugins and engines than the general run of the mill development people involve themselves in. This may be a reflection of Rails maturing as a framework in that it's starting to really support expert level content being published as books rather than disparate blog posts.

The book covers a wide array of the new features in Rails 3, but unfortunately it isn't particularly well organised making it difficult to use as a reference book. Much of the book is spent examining the status of various features of the rails rendering stack, this is interesting information and there's use for it when building something like a CMS, but outside of that I can't see it being used for that very much. Indeed, of the topics that are explicitly addressed I have only needed one of them in the past(Building a translation module for kete using mongomapper)

On the other hand, throughout the book there are lots of little tidbits and functions of Rails that I did appreciate learning and will use in the future. The poor organisation makes this a book to read with a notebook or sticky notes at hand to keep track of things that interest you. And the section of creating custom responders in particular was an interest addition that I'd quite like to try for cleaning up code.

The book suggested layering custom responders on top of custom renders as a powerful way of tidying things up. That might have been the aim in tying things together but I think for most development shops that would lead to entirely too much magic and the code becoming quite opaque to less experienced developers. Worthwhile if you're writing a plugin that needs the powerful generic solution, but not something I want to see everyone using.

One particularly useful bit of coverage is Rails engines, they aren't covered in any section in a particularly focused fashion but are used a lot and the demonstration 'Enginex' gem helps with creating them. If you've been wanting to work with engines this is probably the best overview of them that has been published so far, although that is perhaps more of an indictment of current resources than anything else, hopefully some of the upcoming rails books will deal with them more explicitly.

Is it worth reading? Yes, but there are a lot of other books that you should definitely have read first before this gets to the top of the reading pile. If you're doing a lot of work with plugins or gems, or one of the chapter headings jumps out at you as something you need to do soon, then pick it up with haste. But if it's just on your reading list out of interest then in the Ruby world Metaprogramming Ruby is a more important "advanced" book and I'd also suggest reading more broadly in related technologies before hitting this book.