Refactoring by Martin Fowler should be required reading for every developer that’s been professionally coding for at least a year (although I generally despise it when an author says I should do something). More recently, Sandi Metz has made contemporary these concepts in the Ruby community to great effect…so if you like her books, you should check these out too.
Without a doubt, Refactoring is one of the more practical how-to-make-your-code-more-maintainable books out there. Although at times tedious, the mechanical descriptions of how to do these various refactorings is nonetheless incredibly valuable for the beginner and more experienced alike. Regardless of whether this is your first exposure, or just a reference book for your shelf, you really can’t go wrong with this book.
What do you learn?
Think of this as a cookbook with a few dozen recipes, each one systematically described for when you would use it, how to use it, and what it should look like when done properly. Have a really huge block of procedural logic? Here’s five ways to fix that.
Got a bunch of
select statements stinking up your code…maybe it’s time to
use the magic of Polymorphism to your advantage. You get the idea.
But it’s in Java!?
Trust me, you’ll be ok. Sure, there’s stuff that won’t apply to whatever Object Oriented language you happen to use, but I’m of the general opinion that a developer is a developer once you get some years under your belt. It’ll make sense.
Before Refactoring came out, Kent Beck had written Smalltalk Best Practices which I found to be, in some ways, even better than Refactoring. Sure, Smalltalk is a bit more distant than Java, but it’s fun to learn it along with OO Best Practices. Kent and Martin worked together on Refactoring, so you’ll see the development of the Smalltalk Best Practices as applied to Java in Refactoring.
So…read them both or read either one, it’ll make you a better developer.