Clean Code

Hacker News LinkedIn Facebook Twitter by Abby Fichtner

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!

Be Your Own Boss

So psyched! Am now working with individuals to help them turn their ideas into successful businesses -- as side projects or full time gigs.

Do What Makes You Happy