I meant to write about this book when I first read it last year but I never got around to it and I’m happy that I finally got a chance after my second read this past Christmas break.
First of all, I never read a book twice and the fact that I read this one twice and enjoyed it both times is saying something. It has a ton of useful information and tips for any software developer but if I have to summarize, this book establishes three important points:
1. What does it mean for some piece of code to be clean?
The author establishes what it means for some piece of code to be clean. He shows snippets of code that work equally well but one is impossible to understand while other is much more intuitive and easy to follow, hence more maintainable. He explains why short functions, fewer arguments are better. He answers questions like why and how should you comment, how you should organize your code and why one is better than the other, why dependency injection is good, and so much more. Even if you don’t agree with everything he says, he makes you much more aware about your code and that’s invaluable by itself.
2. Why should you care about and spend time writing clean code?
You’d be surprised how many software developers think that just because some piece of code works, their job is done. They don’t see value in spending time to write clean code. For them, “cosmetic changes” are not really beneficial, code that works is good enough because they forget that they write code for others to understand. Thankfully, the author provides quite a few arguments to show why clean code matters, why code that just works is not good enough, and why “cosmetic changes” are not only beneficial but also necessary.
3. How can you write clean code?
Once you know what clean code means and the value of clean code, the author establishes some rules and guidelines to create clean and maintainable code all the time. He has a set of rules that he outlines in the last chapter as reference. Even though I don’t agree with all of them, it’s good to think about them and come up with your own versions. He goes through a real example and refactors it into clean maintainable code where you can see the benefits.
As software craftsmen, we all have a responsibility to write clean, maintainable, consistent code and this book makes you aware of your code like no other book I’ve read so far, a must-read book for anyone involved in software development.