The Art of Readable Code

Author: Dustin Boswell & Trevor Foucher
Publisher: O'Reilly
Pages: 204
ISBN: 978-0596802295
Aimed at: All programmers
Rating: 5
Pros: Practical, thought-provoking, amusing cartoons
Cons: You may have encountered ideas before
Reviewed by: Mike James

 

If you only read one book this year - make it this one.

It doesn't contain much that you cannot find elsewhere, and if you are an expert skilled programmer then you probably don't need to read it, but it is nicely explained and it has a modern take on the old advice.

There are many programmers who just learn to code without ever really thinking about what they are doing or how to do it. If you are one of these then The Art of Readable Code might open your eyes to better ways to do things - but only if you are ready for it.

The whole book is about avoiding the situation illustrated in the cartoon in the preface. A completely manic looking programmer works late at night on some code. The second frame shows the same programmer much calmer but clearly dejected two weeks later admitting that he has no idea what the code does or who wrote it. The argument is that programs have to be written to allow programmers to read and understand them in the shortest time possible.

 

Banner

 

Chapter 1 makes this argument and if you don't see the sense of it the rest of the book will be so much waste paper to you. In fact, if you don't agree with this basic premise, I doubt you would even understand the many cartoons that pepper the book. As long as you do, you'll find the cartoons highly amusing and a key element in the overall readability of the book.

The first part of the book is about "surface level" improvements which means issues like variable naming, line breaks, alignment, comments and so on. It is an easy read, but don't be fooled. Putting some of this advice into practice is hard, but at least you are now aware of the objective.

Part II of the book is about simplifying loops and logic. This covers how to write logic so that its meaning is clear. Using the ternary operator, types of loops, nesting and so on. The chapter on simplifying expressions so that they are understandable is essential reading. Expressions are a part of the code that seems to escape coding rules and any sort of desire to simplify. Indeed there is a school of programming that delights in writing the most complicated expressions possible to shorten the code.

Part III is on what you could call "refactoring", but it's about more than this. There is a chapter on multi-tasking, or more correctly on trying to keep things to one task at a time.

The book closes with some selected topics, including the subject of how to write readable tests and a final example of coding in a project.

Overall this is an easy read with code in a range of languages - C++, Java, JavaScript and so on. The cartoons actually help by making a point in an amusing way and there are lots of pull quotes to sum things up. You probably won't agree with everything that is recommended to make reading code easier - but you don't have to. The book isn't prescriptive. It doesn't insist that there is only one way to do the job. Instead it explains and argues its points and expects you to evaluate the situation to produce an outcome that satisfies you.

The Art of Readable Code isn't a ground breaking book, but it is an easy reminder of how to do things better.
Highly recommended.

Banner


Administering Relational Databases on Microsoft Azure

Author: Prashanth Jayaram et al
Publisher: Independent
Pages: 622
ISBN: 979-8706128029
Print: B08Y4LBTP4
Kindle: B08XZQJHMK
Audience: Azure DBAs
Rating: 2 or 4 (see review for details)
Reviewer: Ian Stirk

This book aims to help you pass the Azure Relational Database exam DP-300, how does it fare?



The Art of WebAssembly

Author: Rick Battagline
Publisher: No Starch
Date: May 2021
Pages: 304
ISBN: 978-1718501447
Print: 1718501447
Kindle: B08TSYXJTS
Audience: WebAssembly developers
Rating: 5
Reviewer: Ian Elliot
WebAssembly is the coming thing - or so we are told.


More Reviews

Last Updated ( Saturday, 17 March 2012 )