Friday, January 8, 2010

Refactoring – Ruby Ed.

The original Refactoring book by Martin Fowler had a big impact on how I thought about writing software. I’d used the refactoring tools in Smalltalk, but the book changed the way I thought about refactoring and gave names to many new refactorings.

This Ruby edition of the book is highly anticipated. I received my copy at a drawing in our local Ruby user’s group. Part of the deal was you had to write a review (you are reading it) in exchange for the book. Nearly everyone at the meeting wanted a crack at the book.

The authors suggest that if you have the original work, you probably shouldn’t purchase this new edition. I don’t agree. There is plenty of new content with around 20 new refactorings and a few new code smells to make the difference worthwhile. There is a tremendous amount of thoughtful Ruby code snippets inserted throughout the text.

In fact, this is one of those books that is great for everyone on a team to have a copy. It is the kind of book that can be used to raise the quality of communication across the team.

You can see the respect the new authors had for the original work, as the new refactorings jibe with the old. Much of the text remains unchanged, which is good as things like the justification, most of the code smells, and background have aged well. Even the order of the refactorings has been largely preserved, which makes it easy to compare the two editions.

Jay Fields and Shane Harvey have updated the examples and step-by-step examples using idiomatic Ruby. Where the original book used Java for the code examples, the examples were pretty language-agnostic, not using anything from beyond the core SDK and even avoiding things like inner classes in examples. This book leverages Ruby’s strengths.

No comments: