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.
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.
- 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.
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.
His blog is also one of my favourites to read with some pretty accurate quotes:
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