Code and comments

Practical and theoretical aspects of software development

Book Review: Clean Code by Robert Martin

with one comment

Clean CodeI read Clean Code by Robert Martin (Uncle Bob), and it was well worth it. In about 400 pages, Uncle Bob gives real motivation for writing clean code, explains, in careful detail what clean code means for all of the regular parts of a typical system, and then applies the principals discussed on several substantial chunks of real-life code.

Martin begins with motivation to strive to write clean code. That may seem unnecessary, but it serves several good purposes, even for those that were willing to buy a book entitled “Clean Code.” First of all, in Martin’s engaging style , you become excited about the possibility of writing better code. More importantly, in my view, is that rather than appealing to prideful notions of craftsmanship or art, he makes it clear that clean code is about useful, maintainable, flexible software. That it is about reducing the cost of software, and preventing, reducing, and fighting the software rot and decay that often surrounds us.Martin goes on to specify what clean code means, in naming objects, in writing functions and classes, handling exceptions, formatting and, commenting code, among other aspects of software development.

One of the best things about Uncle Bob is that he is not ashamed of his opinions, and that allows him to present a very distinct position on what clean code is. If you also have opinions, you will probably find yourself disagreeing with his assertions at some point. How much you like this book will have much to do with your willingness to consider the arguments for a position that you think is too extreme, or misguided.

I’m not suggesting that Uncle Bob is unreliable. My point is that most authors fearfully hide their convictions to avoid conflict, and hope the reader will be satisfied with that which is bland and obvious, or the results of scientific studies. Such cowardice is inexcusable. When purchasing a book about developing software from an author with decades of experience, we deserve more than what he can prove. We deserve to know what he does, what he believes, and what he suspects. Uncle Bob delivers.

Code Complete

A good contrast to Clean Code is Code Complete, by Steve McConnell. McConnell takes a much more nuanced and timid approach. Recognizing that different methodologies are effective for different people in different situations, he presents a variety of answers to every question, except those questions which are beyond dispute. McConnell manages to include the results of an amazing numbers of studies, which is impressive, and must provide some value. But the value of a voice of experience passionately arguing for what he believes is best seems more valuable to me, even in those cases when you disagree.

Of course, passionate argument can only get you so far, and Uncle Bob backs up his arguments in Clean Code with several extended code examples, where he applies the principles that he has advocated to real-life open source code. It takes some time to work through these examples, but it easily doubles the value of the book and the likelihood that you will apply these principles in the real code in your life.

One warning: All of the examples in this book are in Java. So if you don’t work in Java or C#, this book will have less value for you.

In the end, the best thing about this book is that I consistently write better code after reading it. I expect that you will too. Few books can reliably have that effect, so I enthusiastically recommend Clean Code for every professional Java programmer.

Advertisements

Written by Eric Wilson

December 12, 2011 at 12:41 pm

Posted in reviews

Tagged with , , ,

One Response

Subscribe to comments with RSS.

  1. Excellent points about Uncle Bob. I think you captured exactly why I like his writing.

    Rob Conaway

    December 15, 2011 at 9:20 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: