loading...
Cover image for The ONE book every developer MUST read!

The ONE book every developer MUST read!

lukegarrigan profile image Luke Garrigan ・3 min read

Superpower

Let's face it, us developers live in a very strange world. Explain what you do to 95% of the population and they'll likely glaze over before you've finished your sentence. What you do with a computer day-to-day looks like bloody wizardry to most people, and so it should, programming is a superpower.

It is a superpower that needs careful thought and consideration, particularly for those programmers who are going to have to read your code later.

Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.

The one book I wish every programmer before me had read before writing that 3000 line function is Clean Code - Robert C. Martin.

Picture of uncle bob and clean code

Why Clean Code

This book gave me a whole new perspective, it has restructured the way I think about each line of code. It made me realise that there is an art to being a software engineer.

It teaches:

  • How to identify bad code
  • How to meaningfully name variables/classes/functions
  • How to write clean, small, single-purpose functions
  • When to comment, or rather, when not to comment
  • Guidelines to formatting code properly
  • Using objects and data structures for appropriate data abstraction
  • How to properly follow the laws of TDD and write clean tests
  • Elegant ways to handle errors
  • Endless refactoring tips
  • 67 smells and heuristics (Yes, I counted.🤣)

And much, much more.

Whenever I'm programming I have Clean Code an arms reach away as a reference. The book has tonnes of examples of transforming bad code to clean code and the step by step process on how to get there.

For instance, just the other day I was refactoring a function which violated the single responsibility principle on numerous counts and was scratching my head on how to split it up properly. I consulted the book to jog my memory on an efficient way to get about the process and there was an example exactly like my problem, the only minor difference really being the context.

Uncle Bob

Robert C. Martin (Commonly known as Uncle Bob) is a programming superstar. Not only does he write absolutely brilliant books he is also a very talented speaker. Just YouTube "Uncle Bob" and you'll find a stream of talks he's done, each of them as interesting as the next.

One of my favourite Uncle Bob videos

His blog is also one of my favourites to read with some pretty accurate quotes:

Finally

In my opinion, every programmer should read this book, at least 3 times 😄. It'll give you a whole new love for programming. You'll actually begin to understand when you're writing bad code. You'll look at your old code and wince at its structure, the vertical spacing, the complexity, the out of sync abstractions, the useless comments, and the spaghetti nature. (well, I do, every-single-day). In the book, the code snippets are in Java but the same rules apply to most languages!

This blog is only a brief introduction to the benefits of reading this book, I strongly recommend you have a read if you haven't already. I'd love to hear your thoughts on Clean Code and potentially how it changed your perspective. I'd also love to hear of some other books which have completely altered the way you look at code.

Follow me on twitter if you don't want to miss out on absolutely brilliant programming insight: 🤣 @luke_garrigan

Posted on by:

lukegarrigan profile

Luke Garrigan

@lukegarrigan

English lad currently a C#/Java/VueJs/JavaScript developer. Extra dribbling can be found at https://www.codeheir.com Portfolio found at https://lukegarrigan.com

Discussion

pic
Editor guide
 

I recently finished reading this book with some colleagues at work. The consensus opinion to come out of it is that you won't fully benefit unless you read the book critically. While 80% of the book is good advice, about 20% is controversial to downright bad advice. Plus, most of the book is grounded in quite outdated Java versions, some of it in dire need of an update (and largely irrelevant if you don't use Java).

If you're new to the idea of writing "clean code", you might not be able to recognize the 20% of bad advice. So if you do read this book, remember to take everything with a grain of salt; it's just one more perspective to keep in mind while writing code, not the definitive perspective.

 

If you're new to the idea of writing "clean code", you might not be able to recognize the 20% of bad advice.

This is exactly the point I was making earlier!

Robert Martin has a lot of good ideas, but his apparent ego prevents him from distinguishing between his opinion and provable reality.

I recommend developers learn clean coding from more trustworthy (less egotistical) authors, who have vetted these ideas in their own careers. I can never recommend a young developer read Robert Martin's work directly.

 

I am not a big fan of commenting code, but sometimes it is required (but not always). Developers hardly read comments and most of the time it's just create noise.

Jason, I appreciate your
defensive approach to support code comments, but it's sounds to me an unnecessary conversation. It's all depends on agreement between team members whether to add comments and how much.

Can you please show some respect for Uncle Bob, based on his contributions,

Can you please show some respect for Uncle Bob, based on his contributions.

To be honest, I don't think Jason was disrespectful in any way. He said Uncle Bob has a lot of great ideas. And pointing out that Uncle Bob has a gigantic ego which prevents him from distinguishing between his opinion and provable reality, is just the truth. He is still man with a lot of good ideas.

 

I can never recommend a young developer read Robert Martin's work directly.

Amem to that. There are a lot of good ideas in his books. That's a fact. But distinguishing between the good and the bad advice is difficult when you are just starting to learn how to code.

 

A video by Bob Martin delivered in Norfolk UK blew my mind. It starts off very strangely talking about human biological evolution. That seems very odd but stick with it. He then drops the bomb on what makes clean software architecture which is that everything must be a plugin to your business logic to keep it clean youtu.be/o_TH-Y78tt4

 

Oh god, this kills me, I'm from Norfolk! Such a brilliant speaker.

 
Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer's intent but rather is full of crisp abstractions and straightforward lines of control.

While this may be completely true, it is completely forgetting the archenemy of every programmer, "The Deadline". When you are fighting the clock, and you have a choice, "Make it pretty, or make it work." This is typically when style goes out the window.

 

Yeah, unfortunately, this happens far too often. Especially when the product is new and the business wants to see results fast. It's in the developers' hands though, if they think it's going to take longer to make the code clean, maintainable, extendable then it's their responsibility to let the appropriate people know!

 

Wow, you beat me to it! I'm currently reading this book again and was planning on sharing the same sentiments on here soon 😂

Totally true though, this book is an invaluable resource. Highly recommend that anyone trying to get serious about porgramming takes the time to read it.

 

I love this quote!

Aways code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.

 

Me too! I can't take credit for this one though, I did google around to see who originally said it, but failed miserably!

 

haha it's still a great quote!!! It might be John Woods.

 

Nope. It is full of ill, destructive advice and OOP zealotry. Programmers who took this broken book too seriously are lost, and I personally will never want to have to work with any of them.

 

Thank you for wrapping this up. I absolutely agree that every developer should read this book. The book gives really good advice on how to code and also what to express with code. In my personal opinion, Uncle Bob sometimes is a bit extremistic in making an argument though. He tends to explain a single aspect so sharply pointed, that it can be in the neighbourhood of "wrong" or contradicts his own arguments from other chapters. So when reading the book, each thing should be seen as a proposition how to work. Trying to understand what the author wants to express and how he came there is key to understanding the argument and bringing it to life under the own circumstances.

What I don't like is to see this book as the "Holy Bible of code", which indicates that every single letter has to be obeyed to. Not understanding the rationale but still adhering to the words as they were written can cause all different kinds of new classes of problem.

 

Before this book one should read the Pragmatic Programmer book, that is referenced several times in the Clean Code book, that now have a new edition to commemorate the 20th Anniversary from the first release.

For twenty years, the lessons from The Pragmatic Programmer have helped a generation of programmers examine the very essence of software development, independent of any particular language, framework, or methodology. This classic title is regularly featured on “Top Ten” lists, and many corporations issue it to their new hires.

This new 20th Anniversary Edition offers a fresh look at the modern development landscape, cutting through the “business as usual” and tired advice from the net to help guide you through the next twenty years and beyond. Featuring new tips, new topics, and revisions throughout, you don’t want to miss this one.

 

TL;DR: read the book, take it with a grain of salt, and try to take some of what Bob said into your daily thoughts about how some things are done.

As much as a like this book and it's commentary, this requires every developer that's ever touched a keyboard to live, eat, and breathe this ideology for it to be consistent. That doesn't mean that some of his suggestions can't be used, it's just that if you wanted this to be the holy Grail, it would really need to be executed perfectly.

That being said, look at CPPCoreGuidlines. Good standards based around a community and Bjarne. There are others like it for other languages.

 

good recommendation and I am definitely gonna read this book, if you have good resources pdf of the book, I'd be glad if you send it to me, thanks by the way...

peace.

 

Uncle Bob is one of the amazing software engineers alive today. Read as much of his work as possible. Some really good work.

 

Absolutely true, this book has changed a lot about how I think and write code (excuse me, I meant TESTS)

 

I created a book list for software developer techread.dev
Definitely Clean Code is one of the best book.

 

Great article 😁

 
 

Cannot agree more. Reading this book has changed forever how I see code

 

Exactly! It gives you a brand new perspective

 

I like the book overall, but don't follow it blindly.

Some comments have been hidden by the post's author - find out more

Code of Conduct Report abuse