Please note: this blog has been migrated to a new location at https://jakesgordon.com. All new writing will be published over there, existing content has been left here for reference, but will no longer be updated (as of Nov 2023)

Book review - The Art of Readable Code

Sat, Dec 31, 2011
The Art of Readable Code by Dustin Boswell and Trevor Foucher

In my recent visit to the Computer History Museum I had a few hours to pass on a flight from San Jose to Seattle, and I spent it with a new book in the genre of ‘self help for programmers’

It’s a really easy read in 14 clean (and short) chapters:

  1. Code should be easy to understand
  2. Packing information into names
  3. Names that can’t be misconstrued
  4. Aesthetics
  5. Knowing what to comment
  6. Making comments precise and compact
  7. Making control flow easy to read
  8. Breaking down giant expressions
  9. Variables and readability
  10. Extracting unrelated subproblems
  11. One task at a time
  12. Turning thoughts into code
  13. Writing less code
  14. Testing and readability

As a fairly experienced developer, I found it mostly a review of ideas and patterns I have already come to agree with, that the author sums up nicely as:

Code should be written to minimize the time it would take for someone else to understand it

I don’t always succeed in that with my own code, but the further I get in my career, the more I appreciate just how important it is to write code that can be understood, maintained, and enhanced by others.

As such, I pretty much agree with all of the author’s points, and one piece of advice I was particularly happy to see:

Naming Test Functions - Don’t be afraid of having a long or clunky name here. This isn’t a function that will be called throughout your codebase, so the reasons for avoiding long function names don’t apply. The test function name is effectively acting like a comment.

I am usually aggressive about short, but meaningful, names… except when it comes to my unit tests when I sometimes go a little crazy with long descriptive test names, so its nice to read something that helps me understand why I do that!

When I’m learning something new (such as the Android platform), I’ll surround myself with books about that specific technology, but in general I much prefer these kinds of ‘make yourself a better programmer’ books.

If you like these kinds of books, (you are a programmer, right ?), then don’t forget to check out these similar titles:

… and I assume you already own at least 2 copies of the first one on that list :-)