Clean Code – Book Review – Is it Useful for Software Engineers?
Posted on April 12, 2020
Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin (aka Uncle Bob) is the first book of the series named after the author from Prentice Hall, Pearson. Originally published in 2008, it represents a classic and still relevant resource for coding best practices, presented in the context of Agile principles.
What Is Clean Code About?
Clean Code‘s premises can be defined as follows:
- There is underlying complexity in the business being modeled by software.
- There is technical complexity in the system modeling said business. It is added on top through high-level design (system architecture) and low-level implementation (code).
- There is social complexity between the project’s stakeholders in their effort to have a precise collective understanding of both the business and system.
- If left unmanaged, any of the three can quickly grow to the point at which project progress becomes impossible (growing entropy).
Consequently, reducing complexity in any of these areas will slow down the entropy increase and hopefully even decrease it. Thus the team can be effective in satisfying the business goals constantly and consistently.
The book defines code as the greatest common denominator and dedicates the bulk of its pages to describing in great detail how to write so-called clean code. All chapters align with the principles of the original Manifesto for Agile Development down to the smallest note, very clearly explaining why and how a recipe works to decrease complexity.
What Will It Teach Me?
- That code is the element that binds all stakeholders together in any software-related project
- How to write code that is easy to understand and maintain by following a set of recipes. All the concepts are relevant for object-oriented code and system architecture, but many can be adopted in functional programming too.
Who is this Book For?
I was tempted to say that this book is for everyone, but it isn’t so. Basic recipes like good naming practices and formatting may be up anyone’s alley, but a thorough understanding of the content in its entirety requires some prior knowledge.
Prerequisites for Making the Most of Reading Clean Code
- A decent understanding of object-oriented programming (classes, polymorphism, composition, aggregation). I would mark this one as a must-have.
- Be aware of basic software architecture concepts (application layers, (such as MVC), client-server/n-tier. This is somewhat optional, as the architecture concepts used in the book are not too advanced and can be learned on the fly.
- Basic understanding of concurrency (threads and synchronization). This one is optional too, as there is one chapter dedicated to concurrency and can be skipped if out of reach. You still get to benefit from the other 16.
Does Clean Code Have Code Samples?
Yes, it has comprehensive Java code samples. Fear not, they are written in a way that any programmer familiar with object-oriented programming can understand apart maybe from a few Java-related subchapters.
Are the Teachings of Clean Code Controversial?
The techniques themselves are mainstream and SOLID (pun intended). What you may find open for debate are the extents to which to apply them. For instance statements like “a method should have at most 5 lines, otherwise, it should be refactored” or “a method should have zero, one or at most two arguments” are viewed by some as unrealistic in the real world.
Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin is a must-read for any self-respecting software engineer. One may not agree with the strictness of some of the recommendations, but the techniques and benefits of the discipline described therein are undebatable.