Refactoring by Martin Fowler - Developer must have
Late last year I was spending a lot of time on trains between T.O and Montreal, on one trip I picked up this book and was thoroughly engrossed - Refactoring - Martin Fowler is one of those simply must-have books on any developers bookshelf. Of all technical books I’ve found it to be the one that actually compels you to be a better programmer.
The first chunk of the book is dedicated to whats, whys, testing etc of how you should turn your mish-mash of spaghetti code into beautiful elegant world class code, the rest of the book is dedicated to a catalog of various examples of refactorings.
Each refactoring is structured with a small class diagram, theory about why you want to do it, then a detailed walk through of the steps written to get there. Well written, most of them are a doddle to understand. Even though the book uses examples in Java, they equally can apply for your Ruby, PHP, Actionscript code or whatever else tickles your fancy.
If you want to change from a programmer to a code artisan, this is the book for you. If not we’ll leave you alone with your unmaintainable spaghetti code. Some of the refactorings are obvious, and some the light switches on and you go ‘a-ha’. Certainly if I’d have had this book from day 1 many moons ago I would’ve been a much happier chappy. I know using principles in the book I came away refactoring a working but messy piece of code days after reading it - the principles learned in the book made it a lot easier and quicker to do.
One big personal improvement I made was towards not being afraid of breaking up functions for readability e.g. like so:
class MyClass def able_to_checkout if ( ugly_condition_1 == a && ugly_condition_2 == c && you_get_the_picture ) self.set_book_to_checked_out end end
(guilty as charged) to the following:
class MyClass def able_to_checkout if ( no_books_checked_out? ) self.set_book_to_checked_out end end def no_books_checked_out? ugly_condition_1 == a && ugly_condition_2 == c && you_get_the_picture end end
To round off the book, it’s a hard cover with a little red cloth tape bookmarker. What other technical book have you seen with that in recent history ? It’s been designed to stay on your shelf for a very long time - unlike some faded examples gathering cobwebs on mine. A rare timeless classic ? Quite possibly. Go out and buy it today if you haven’t already.
Another 10 | 10

2 Comments, Comment or Ping
Peter Bell
For anyone on a Fowler kick, I’d also recommend the Patterns fo Enterprise architecture. He’s just a great communicator and there’s lots of wisdom distilled into that book - even if it is a little pricy.
For refactoring, also check out “refactoring to patterns” - a very god read.
Jul 26th, 2007
Peter Bell
Oops - typo day today. “Patterns OF Enterprise . . .” and the second book is not theological - it is a GOOD read.
Long night :-
Jul 26th, 2007
Reply to “Refactoring by Martin Fowler - Developer must have”