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


T-SQL Fundamentals (Microsoft Press)

Author: Itzik Ben-Gan
Publisher: Microsoft Press
Pages: 608
ISBN: 978-0138102104
Print: 0138102104
Kindle: B0BTLBXF8V
Audience: T-SQL developers
Rating: 5
Reviewer: Kay Ewbank

Itzik Ben-Gan is a highly respected Microsoft Data Platform MVP, and the earlier editions of this book were already ver [ ... ]



Principled Programming

Author: Tim Teitelbaum
Publisher: DateTree Press
Date: March 2023
Pages: 429
ISBN: 978-8987744109
Print: B0BZF8R467
Audience: General
Rating: 5
Reviewer: Mike James
Principled Programming - what else would you want to do?


More Reviews

Last Updated ( Saturday, 17 March 2012 )