Clean Code
05/02/10 20:49

Clean Code: A Handbook of Agile Software Craftsmanship focuses on the importance of the source code itself. I’m already familiar with Robert C. Martin’s Agile Software Development: Principles, Patterns, and Practices so I expected something similar but focused on the code instead of on design. I was not at all disappointed.
Please don’t let “Uncle Bob”’s book titles scare you away. There is some focus on the agile methodologies but nothing is really being pushed on you. Agile enables more of a focus on the code and testing which is the main point.
Martin begins with an argument for writing clean code and caring about the readability of code. I did not require convincing myself but I’m pretty sure there are still a lot of people out there that still believe getting code working and walking away is still acceptable practice. What follows is the real meat of the book.
The book covers horizontal and vertical spacing, code comments, choosing meaningful names, handling third-party code, unit testing and everything else you would expect a book about coding would cover. Martin goes so far as to pick sides as well and does not hold back on expressing his opinions. I think we all respect an author that is willing to take sides.
The book then takes a turn into more unfamiliar territory. The systems level is discussed with ideas on design aspects, frameworks and even domain-specific languages. Emergent design, refactoring and the wonderful world of concurrency (ex. multi-threading) is also explored in some detail. These chapters were a surprise for me as I did not expect to find such a wealth of information in a single book.
Real examples on open source projects are presented along with all the advice. Martin takes us through how to take a badly written pile of bits and turn it into what he calls “clean code” step by step. There is a lot of great detail on how and why he chooses to do what he does but it does drag on for a while so be prepared to put some work into reading it.
The book concludes with a collection of “Smells and Heuristics” which help bring everything together.
The first section on concurrency was a little scant so it was decided to put a full appendix dedicated to concurrency at the back of the book. This is a valuable appendix with useful information for anybody dealing with concurrency in their code base.
There is a lot of good information in Clean Code but it does have the same flaw as all other books on coding have. The author must choose a programming language to make the book useful. This time it was Java 5 that was chosen so it would be a good idea to brush up on your Java to get the maximum amount of use out of this book.