"Clean Code" by Robert C. Martin
Published by Prentice Hall
Buy at Amazon.com -
(5 stars out of 5)
I knew I was going to like this book after I read the Foreword and
Introduction. I know not many people read those and as an author
myself this bothers me, but it gives insight to why the author has
written the book, which is a very important thing to understand. I
was hooked by the affirmation that details are important and that
the only meaningful metric is the number of "wtfs" per minute in a
code review. For a long time I have kept my "profanities per test
session" metric as a way to measure software usability.
Long before I was a software testing guy, I was a coder. Back in
those days it was common for rookie coders to sit next to guys with
gray hair and bad breath (or if lucky next to ladies with better
appearance and who smelled better) to learn the craft of writing
code. Yes, coding was a craft before the attempt to make it an
engineering discipline. Although there was a lot of bad code, there
were plenty of people who took pride in how they coded. This book
reminds me of what it was like to sit next to these intelligent
people as mentors.
I have often lamented that today's young coders don't have this
mentor/apprentice relationship. A reasonable facsimile would be to
read this book and practice these very sensible and helpful lessons
in coding. As a testing guy who has been through those 30 wtf/hour
code reviews, my bulletin to developers is that: Your code can be
better! This book can show you how!
Here's one example: Have meaningful names. Instead of a function
named "int d", how about "int ElapsedTimeInDays;"? There's a whole
chapter about naming things. It reminds me of the coder I knew that
liked to label COBOL paragraphs after towns and cities in Kansas.
Why? So he could write GOTOs that read "GOTO Topeka." He thought
that was cute but the rest of us found it confusing and not-so-cute.
I also appreciated the chapter on Unit Testing. As a tester, I love
it when testing is mentioned, but Martin actually has specific
guidance on what makes for good Test Driven Development and Unit
This book is very readable, makes a lot of sense and would make
most coders better. For testers that sit in on code reviews, this
would be a great read for understanding how good code should be. I
wish every coder in college or tech school would read this book
before unleashing their creations upon the world.