Clean Code Review— A must-read Coding Book for Programmers | by javinpaul | Javarevisited | Medium
Clean Code Review— A must-read Coding Book for Programmers
Want to learn the art of converting bad code to good code? This book can help, worth reading for Java programmers.
image_credit — Clean Code book
Even though the Clean Code book was released many years ago and there are lots of good reviews already available, I couldn’t resist writing my own experience of this great book. I came across this book many years ago, but since then, I have read it multiple times, and I have recommended it to my readers, students, and fellow developers.
It is one of those books which make you feel that why didn’t you come across it earlier, I felt the same when I first learned about this book. The Clean Code book is all about writing good quality code, and how do you judge the quality of code?
Well, you won’t appreciate good until you have seen bad code and that’s what this book does.
It first presents a code, which is ugly, hard to read, hard to understand, hard to maintain, and then Uncle Bob goes step by step to refactor that code and converting them into the masterpiece you would be proud of writing.
You will get a taste of how to convert a bad code to good code when you first read his example of an algorithm to generate the first 100 prime numbers. He has explained how to write clean code by with the Sieve of Eratosthenes is a very nice way.
Here is another example of good code vs bad code which I found on LinkedIn and it nicely captures the idea of clean code.
image_credit — Pushkar
Some of you might argue that what is all about the clean code? If a code can function, then it’s just enough. Well, it’s not. We all think about that when we used to write programs in a computer science lab, our educational projects and on our semester practical exams but the real world is totally different, here you learn the Art of Writing Clean Code.
One reason for that is because it’s not a throwaway code, it will remain longer than you expected. For example, some of the pricing systems in Investment banks are still running on mainframes, which is more than 40–50 years old.
If a code isn’t clean, it can bring the company to its knees and reduce its ability to remain competitive by providing cutting-edge solutions. Since a Code needs to be maintained in most of his life-span, it must allow you to maintain and extend, and that’s what clean code does.
It’s also easy to refactor which is another technique to write clean code. If you want to learn more about refactoring I suggest you to join Pyramid of Refactoring (Java) — Clean Code Gradually course on Udemy, its very hands-on course to learn Refactoring technique in Java, and if you need more choices, you can also checkout this list of best Refactoring courses for Java developers.
Is Clean Code Worth Reading? Review of Clean Code Book
The Clean Code book is well structured and divided into three main parts. The first part talks about principles, patterns, and practices of writing clean code. This is where I first learned about SOLID design principles, and it changed the way I write code.
For example, if I didn’t know about the “Open Closed design principle,” I wouldn’t have understood the full power of Polymorphism and Abstraction ever.
These little principles not only help you to understand fundamentals better but also help you to write better code, which is easier to understand and maintain.
The second part is full of real-world case studies of increasing complexity. Each case study is an exercise of turning a bad code into good code, something which easier to read, understand, and maintain.
By the way, clean code is not just about architecture but also about debugging and performance, a code that is easier to read is also easier to debug and optimize.
The title “Clean Code: A Handbook of Agile Software Craftsmanship” fully justify the content inside the book because coding is no lesser than Craftmanship and his argument that “Even bad code can function. But if the code isn’t clean, it can bring a development organization to its knees” is perfectly valid.
The third part is the most important, a payoff, like a single chapter containing a list of heuristics and code, smells gathered while creating the case studies. You can use this chapter as a knowledge base that describes the way we think when we write, read, and clean code.
The book is full of programming best practices, I mean correctly naming variables, classes, and methods, some of you can find it here as well.
It also put a lot of emphasis on unit testing and test-driven development which is one of the attributes of a professional programmer and something which distinguishes them from amateur programmers.
In short, must-read books for the programmer, and after reading this book, you should be able to
- Tell the difference between good and harmful code.
- write good code and how to transform bad code into good code
- Create good names, good functions, good objects, and good classes
- Format code for maximum readability
- Implement complete error handling without obscuring code logic
- Unit test and practice test-driven development
Btw, if you are interested in not just a book but also some online training courses to improve code quality, I suggest you check the free course, Clean Code: Writing Code for Humans by Cory House from Pluralsight.
You can get it absolutely free by signing for the 10-day free trial; which allows you to watch 200 minutes of any course. Anyway, Pluralsight is full of such gems, and its monthly membership is what every programmer should consider having.
That’s all about review of “Clean Code: A Handbook of Agile Software Craftsmanship,” one of the must-read book for any developer, software engineer, project manager, team lead, or systems analyst who want to write better code. So, if you just want to do one thing at this moment, just go and read the Clean Code. It’s worth every penny, and every second you spend.
Other Programming resources and Books you may like
Thanks for reading this article so far. If you like this Clean Code book review then please share it with your friends and colleagues. If you have any questions or feedback then please drop a note.
P. S. — If you are looking for online courses to learn Design patterns for writing clean code then I also suggest you take a look at the Design Pattern in Java course by Dmitri Nestruk on Udemy. It will greatly improve your understanding of writing robust and easy to maintain object-oriented code in Java.