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


Scalability Rules

Author: Martin L.Abbott & Michael T. Fisher
Publisher: Addison-Wesley, 2011
Pages: 272
ISBN: 978-0321753885
Aimed at: Web developers, architects and managers
Rating: 4
Pros: Well thought-out, readable style
Cons: Format leads to repetition
Reviewed by: Alex Armstrong

This small format book is summed up [ ... ]



Getting Started with the Internet of Things

Author: Cuno Pfister
Publisher: O'Reilly, 2011
Pages: 192
ISBN: 978-1449393571
Aimed at: Beginners
Rating: 3
Pros: Explains the NetDuino approach
Cons: Not suitable for beginners
Reviewed by: Harry Fairhead

A book about using the Netduino Plus and the .NET Micro Framework to connect devices to the internet [ ... ]


More Reviews

Last Updated ( Saturday, 17 March 2012 )
 
 

   
RSS feed of book reviews only
I Programmer Book Reviews
RSS feed of all content
I Programmer Book Reviews
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.