No Starch Press – The Art of Clean Code by Christian Mayer

I’ve received a review copy of this book, which looked particularly interesting as it promises to provide help and guidance on writing better code.

How could I possibly resist?

Cover of The Art of Clean Code showing two robots in a lab distilling a drop of liquid from a flask
Image: No Starch Press – The Art of Clean Code by Christian Mayer

The table of contents are as follows:

  • Introduction
  • Chapter 1: How Complexity Harms Your Productivity
  • Chapter 2: The 80/20 Principle
  • Chapter 3: Build a Minimum Viable Product
  • Chapter 4: Write Clean and Simple Code
  • Chapter 5: Premature Optimization is the Root of All Evil
  • Chapter 6: Flow
  • Chapter 7: Do One Thing Well And Other Unix Principles
  • Chapter 8: Less Is More in Design
  • Chapter 9: Focus
  • Letter From The Author

So far, I have thoroughly enjoyed the book, with excellent insight throughout the chapters I have read so far (Chapters 1 – 3).  Chapter 1 takes a look into the dangers of allowing complexity to fog your vision and also your time.  Rightly so, by simplifying and keeping things simple you most certainly ensures that you can focus on one thing at a time and ensure it is done well.  Each time you add complexity your attention becomes divided and your target delivery becomes more distant (and often your customer less happy).

Chapter 2 takes a look at the concept of the 80/20 rule, by which I’ve often known heard it said the last 20% of the project can take 80% of the time and other similar examples during my career.  The author demonstrates not only how similar unbalanced relationships exist but also how you might be able to pull them to your advantage.  Also, by drawing upon the benefits of focusing on specific tasks or actions which can best impact how you may flourish within these relationships.  However, while well placed to be applied in many of the practical areas explored, I don’t wholly agree they would be ideal to applying these methods to all things, specifically the concept of identifying specific topics to focus upon within your career.  While applicable at certain times through someone’s career or in specific industries, often a broader approach can often be more benefitable (as least in my opinion) particularly earlier in order to establish a broad set of skills and knowledge to support their later career.  However, I welcome a different viewpoint and often it depends where and how you apply it.

Chapter 3 provides a very important reminder that releasing something can be better than releasing nothing at all. This chapter clearly explains how if you reach for perfection (also bearing in mind the 80/20 principle previously discussed) you may never get there before the opportunity has gone. It brings to mind the classic story of the frog who jumps 1/2 the distance remaining each time they jump…they will never reach the end no matter how long they keep jumping – halfway right now is far better than 100% never!  Similarly, when you finally get to your perfect solution, chances are, you have already wasted a huge amount of effort on things which are of little interest to you users (your guess can never be as accurate as trying it out within the market).  I really like the core messages within the chapter, since I relate strongly to this with many of my projects.  The times when I released something early, got feedback and built a userbase, it not only encouraged me to stick with the project, but it also helped guide me in totally new directions.  One of the first things I emphasize to new graduates is that Work In Progress isn’t of any use until you release it – minimise waste by keeping WIP as small as possible.

It brings to mind the classic story of the frog who jumps 1/2 the distance remaining each time they jump…they will never reach the end no matter how long they keep jumping

Halfway right now is far better than 100% never!

Coming back to the book after short break, I was keen to see what else this book had to offer and I wasn’t disappointed.  Chapter 4 and Chapter 5 dig more into overall code and design principles, which is probably where seasoned coders/engineers will consider to be the meat of the book.

Chapter 4: Write Clean and Simple Code

The merit of writing clean code is adding more code and performing maintenance is quicker

Chapter 5: Premature Optimization is the Root of All Evil

I’ve come across the concepts introduced in this chapter more through DevOps methodology than perhaps coding outlined here. The overall principle being that you should first identify the bottlenecks and focus your optimization on those first – essentially gather your metrics and apply system thinking.

Again the author outlines these concepts very clearly and provides strong tie-ins to the principles introduced throughout the book.

Chapter 6 – although a slightly smaller chapter brings with it another important lesson – allow yourself time to stay within flow (if you’ve not come across the term flow, then you’ll have to read the chapter yourself – since it explains it far better than I can in a few words).  As you progress in your career it can be harder and harder to make time for it – usually because you have many more responsibilities that you will have to context-switch many times a day. However it is totally true that your most productive time is when you reach your flow state, so multi-tasking can often disrupt this.  Even if you can’t save yourself, as you progress you can at least consider your team and protect them instead – hence one of the key roles of a Scrum Master is to protect the team from external distractions, making room for productive flow!

Chapters 7 brings together all of the principles discussed so far and relates them to the Unix principles.  This outlines how these have made Unix so successful and how these techniques can be applied to Python and general software development processes.  Chapter 8 takes a look into UX (User eXperience) design and how simple focused design can benefit both the programmer and the user – after all less is more right?

Finally in Chapter 9, the author sums up all the lessons from the book, while underlining the key tool for realizing these, Focus.  Without Focus all the effort you apply (or that of your co-workers, project team or employer) might end up cancelling itself out as you push and pull in different directions – you need Focus so that you apply a constant pressure in a specific direction, while avoiding context switching (i.e. use of Flow) to use that effort most efficiently. This is why tools such as planning, roadmaps, setting milestones and system thinking can all enable multiple teams and stakeholders to build common understanding and direction. Of course, building common tools, training and processes will also enable your teams to align their methods and ways of working too.

Overall, this has been an excellent book packed full of insights that every programmer (and project manager) should know.  It has certainly been a book that has enabled me to think deeply about the projects I do both in my spare time and professionally.  Even if you don’t agree with every idea or concept within its pages, the book provides an excellent device for deeper reflection, determining where things may apply or how they can be used in the future.  Indeed it would be an idea book for a professional book group to study, with clear chapter topics which enable discussion into all facets of project processes, to share their experiences (positive and negative) and how they relate to the various themes.

My only minor thought is that I would have liked a few more coding type examples, design patterns, technical detail etc. however, I don’t think that was the goal of the author and would probably detract from the intended focus of the book.  I suspect because it has “code” in the title, my expectations were more low-level coding tips and techniques rather than the higher level project view of coding…Still exceptionally useful and interesting all the same.  Of course with such a great foundation, there of course no reason why the author’s next book won’t dig further into that area too, where I’m sure they have plenty to share.

What this book needs is a poster that summaries all the content so you put a helpful reminder on the wall

….Well the author has that covered too!

By the end, I found myself thinking, “What this book needs is a poster that summaries all the content so you put a helpful reminder on the wall”….Well the author has that covered too! They include a link at the end of the book, allowing you to print your own poster for the office. Although I could link directly to it here, I don’t think you’d get the full value without going on the journey first – it is time well spent and a nice ride after-all.