Thursday, September 13, 2018

Clean Code by Uncle Bob - Book Review - Must read for Software Engineers

Even though, the Clean Code book has been released many years ago and there are lots of good reviews already available, I couldn't resist to write my own experience about 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 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 do.

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 about an algorithm to generate first 100 prime numbers. He has explained how to write clean code by with the Sieve of Eratosthenes in very nice way.

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 need to write code for Humans, not just machines.

One reason of 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.

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 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 real-world case studies of increasing complexity. Each case study is an exercise of turning a bad code into a good code, something which easier to read, understand, and maintain.

Btw, the clean code is not just about architecture but also about debugging and performance, a code which is easier to read is also easier to debug and optimize.

The third part is the most important, a payoff, i.e. 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.e. properly 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 professional programmer and something which distinguish them from amateur programmers.

Clean Code by Uncle Bob - Book Review - Must read for Software Engineers

In short, a must read books for programmer and after reading this book you should be able to
  • Tell the difference between good and bad 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

That's all about "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 Clean Code. It's worth of every penny and every second you spend.

Btw, if you are interested in not just 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 10-day free trial, nonetheless, Plurasight is full of such gems and its monthly membership is what every programmer should consider having. 

No comments :

Post a Comment