Clean Code

Clean Code: A Handbook of Agile Software Craftsmanship Bob Martin’s Clean Code: A Handbook of Agile Software Craftsmanship is finally out and the UPS man just dropped a shiny new copy on my doorstep. It kicks off with these fine words of wisdom:

The only valid measurement of code quality: WTFs/minute

Thought I’d take you with me on my quick skim in case your UPS man wasn’t as nice…

Chapter 1 begins with “You are reading this book for two reasons. First, you are a programmer. Second, you want to be a better programmer. Good. We need better programmers.” Includes sections like The Total Cost of Owning a Mess.

Hookah-smoking caterpillar from Alice in Wonderland

The Functions chapter earns bonus points for its opening image of the hookah-smoking caterpillar from Alice in Wonderland. I’m not quite sure what Uncle Bob is suggesting here, but this chapter includes goodness to the likes of Have no side effects, Prefer exceptions to returning error codes, and classic Uncle Bobness such as:

“Functions should do one thing. They should do it well. They should do it only.”

The Formatting chapter explains how to avoid “a scrambled mass of code that looks like it was written by a bevy of drunken sailors” (hmm, I think I’ve seen that code before). And the Objects and Data Structures chapter (which starts with an image of Data from Star Trek – I swear I couldn’t make this stuff up) has some interesting looking sections like Data/object anti-symmetry, The law of Demeter, and Train wrecks.

The book talks about Emergent Design (Simple Design Rule 1: Run All the Tests, Simple Design Rules 2-4: Refactoring) and, of course, the principles of good class design. It covers exception handling (written by Michael Feathers, very cool), dependency injection, aspect oriented programming, concurrency (including thread-safe collections and testing threads), logging, unit testing (including JUnit internals), and code smells & heuristics.

And just gobs and gobs of code examples. The back of the book promises that readers will come away with:

» How to tell the difference between good and bad code
» How to write good code and how to transform bad code into good code
» How to create good names, good functions, good objects, and good classes
» How to format code for maximum readability
» How to implement complete error handling without obscuring code logic
» How to unit test and practice test-driven development

You can find the complete table of contents on Bob Martin’s Clean Code, Whew!


34 responses to “Clean Code”

  1. Object-Oriented Sammy Avatar
    Object-Oriented Sammy

    Thank you!
    People at work make fun of me because I always say, Keep It Atomic 🙂

  2. Abby Fichtner Avatar
    Abby Fichtner

    You’re quite welcome. I’m now a good ways into the book and I can promise you it does not disappoint.

    It’s probably somewhat unnatural to laugh out loud so much while reading a book on code, but here’s where years of working with crappy code can really pay off because it just makes his examples of what not to do that much more amusing.

    “oooh, yeah, I remember back in the day when we thought it was okay to put our entire program into main() – talk about code looking like it was written by a bevy of drunken sailors.”

  3. Object-Oriented Sammy Avatar
    Object-Oriented Sammy

    lol Exactly!
    I listened to you and added it to my amazon wishlist 😉

    Have a lovely day Abby!

Leave a Reply

Your email address will not be published. Required fields are marked *