Showing posts with label book review. Show all posts
Showing posts with label book review. Show all posts

Sunday, April 19, 2009

Review: Clean Code

"Clean Code"by Robert C. Martin is not a conventional programming book. It's not about a new language, framework, methodology or tool. It's about how to be a better developer.

As such, it has much in common with books likeCode Complete,Effective Java,The Pragmatic Programmer,Refactoring, andImplementation Patterns, all of which fall into a genre I've dubbed "self-help books for software developers". I'm not being dismissive here: after all, systems can be just as dysfunctional as families. As developers, we can benefit from some good advice on how to cope.

Much of the advice that "Uncle Bob" dispenses will be familiar to readers of those other books. (Indeed, "Clean Code" references "Refactoring", "Implementation Patterns" and "The Pragmatic Programmer" quite extensively.) I find this redundancy comforting rather than disappointing. After all, if all these books disagreed about what the best software development practices were, how would you know which advice to follow?

(However, there is a certain irony in having read about the DRY principle - "Don't Repeat Yourself" - in three different books.)

Despite the commonalities with its predecessors, "Clean Code" is more than just a rehashing of old advice. The unique aspect of "Clean Code" is the section near the end of the book where "Uncle Bob" uses the principles laid out in the preceding 12 chapters to refactor samples real-world code drawn from the JUnit testing framework, the JCommon library, and his own work.

It was fascinating to see perfectly functional code iteratively refactored into "clean code" much better suited for reuse and further extension. Other books have explained this principle and demonstrated it on small pieces of example code, but only in "Clean Code" have I seen it applied to widely-used open-source code.

If you've ever wanted to refactor some dysfunctional code but not known where to start, or doubted that the end result would justify the effort, you should read Martin's book; it will give you the hope and confidence to give it a try.

Review: Programming in Scala

I first heard about Scala from Elmi, a co-worker of mine who was messing around with functional programming languages in his spare time. His obsession with lambdas and monads seemed peculiar at first, but when pressed for an explanation, he made a persuasive case for Scala, so I decided to check it out.

The documentation at the Scala website certainly sparked my curiosity. After learning about Scala's innovative features and reading some impressively concise Scala code, I understood why developers like Elmi were so excited about it. However, even after reading the free documentation, I felt like I was still missing something, so I caved in and bought a copy of"Programming in Scala" by Martin Odersky, Lex Spoon, and Bill Venners.

Typically, the first book written about a language isn't necessarily the best book about that language, but Odersky, Spoon and Venners have set the bar fairly high for authors of subsequent books about Scala. Higher-order functions, closures and partially-applied functions are probably going to seem quite alien to most developers unfamiliar with functional programming, so the authors are to be commended for explaining those concepts so well. Likewise, Scala's case classes, type inference system, and implicit conversions also get excellent treatment. "Programming in Scala" filled in the gaps in my understanding of Scala with remarkable thoroughness.

(Ironically, I suspect that the excellence of "Programming In Scala" is only partly responsible for the Jolt Productivity Award it recently won; an equal share of the credit - if not more - should to the Scala language itself. My hypothesis is that the Jolt Award voters, deprived a "Best Language" category in which to register their enthusiasm for Scala, rewarded the only published Scala book instead. Fortunately, since the creator of the language is one of the book's authors, there's no controversy here.)

I wholeheartedly recommend "Programming in Scala" to any developer currently working with Java. I'm convinced that Scala is destined to become an "everyday" language on the JVM, and knowledge of Scala will be essential for any well-rounded Java developer. Even if I'm wrong, and you never get to write a line of production Scala code, this book will improve your understanding of Java by demonstrating an alternative approach to inheritance, abstraction and typing in the JVM.