The Art of Readable Code

Dustin Boswell , Trevor Foucher (2011)
Review date: March, 2013
Summary

This is a book about the most fine-grained components of a program, about the code itself. It treats topics like naming, commenting, code layout, variables, but also control structures and readability in general. Its philosophy is to illustrate core concepts with code examples (lots of them) and discuss what's good or bad about the approach.

It ends with a chapter on testability and a longer example.

Opinion

Books like this one are rare - of good quality, with contents that are immediately applicable, and written in a humble tone. In general, there are too few books out there that actually make the reader a better programmer. This is one of them.

For a start, this book lives up to its title. In the first chapter the reader encounters the Fundamental Theorem of Readability, which states: "Code should be written to minimize the time it would take for someone else to understand it." The rest of the book follows this theme. Pretty much all of its contents are condensed good advice, so I'll just pick some examples:


There are other gems in there as well. To me, a discussion about returning early from a function felt important. It's one of these things that developers tend to fight over, and the matter is settled in one of the chapters. I also liked the notion of and encouragement to use "write-once variables", which is sort of consistent with a functional approach, but also a good piece of advice for programs written in a non-functional language.

Then there's an example of taking the "Extract Method" refactoring too far. The authors demonstrate a sound non-dogmatic approach to code and to applying principles.

Of course, there are some passages in the book that aren't in line with what I'd call the best recommendation, but that's rather subjective.

I can't restrain myself from comparing this book to Clean Code, and I have to say this one is the winner. It's less dramatic, has more examples and a more relaxed approach. You feel happier reading it. Just like Clean Code does it target novice or unskilled developers, but just as the former does it contain some advice that even the most experienced developer would find useful.

What's also cool about this book is that the authors use several different programming languages to illustrate the points or make the examples more realistic/applicable.

Is there anything bad about this book then? Well? Not really, except for my feeling that reading it gives diminishing returns. The authors throw their best at the reader in the beginning, while saving less polished contents to the end (not entirely uncommon), so I'd say that you could stop reading after one half or three quarters of the book and still learn a lot. Apart from that, nothing. It's an excellent book, especially for novices, and it sure makes my Newbie Developer reading list.

Who should read this book

While primarily being useful to novice or unskilled developers, this book should probably be in every developer's bookshelf. You'll write better code after reading it.




News

  • 2015-09-29

    It's been almost one and a half year since I reviwed a book! I've been too absorbed by Writing my own. Anyway, I'm back with Jeff Patton's relatively...
  • 2014-01-04

    New category! Performance! Reviewed The Every Computer Performance Book. Check it out!
  • 2013-09-10

    Reviewed a book that' slightly less technical, but much more fun to read. It's I.T. Confidential.
  • 2013-08-13

    Reviewed yet another book on Visual Studio 2012 and TFS. I also created a "Microsoft" category and moved the other TFS book there from the "Tools"...
  • 2013-08-05

    Updated the FAQ. Included information about getting a book reviewed.