I recently had the pleasure to attend a few lectures by Robert C. Martin, also known as Uncle Bob. He’s a software consultant, speaker and fierce advocate of agile methodologies as well as TDD. Not only were the talks entertaining, but also deeply inspirational.
Seeking more information on his ideas, I decided that it would be good to take a look at his flagship book, Clean Code.
And so I read it.
It has definitely changed me as a developer. I cannot look at code the same way anymore.
Clean Code offers a set of very simple guidelines to help us improve the quality of our codebases little by little.
You start by looking at that unholy class nobody dares to touch. Once you get the gist of it, you realise some methods and variables should be named differently, for clarity’s sake. Immediately after, you identify some duplication and factor that out into a different function. Later on, you decide that a particular method is too big and it should be broken down. Maybe this class is doing too many things, lets split it up into smaller classes that do one thing and one thing only.
Oh my God, suddenly that monolithic satanic pile of garbage has been tamed. Future developers (including yourself) will be able to understand it and work with it much better.
Hang on! How can we make sure that it still works?
As developers, it is very much our professional duty to work in such a way that allows us to thrive in the long run. We can only deliver and maintain a large project if we keep things under control. Doom is certain if we do things quick and dirty and absent discipline.
Clean Code is far from being the panacea but it does provide us with quite a few tools to work towards that goal. Uncle Bob exposes the reader to several practical exercises. A piece of bad code is listed, studied and refactored step by step until it becomes a much readable, cleaner and correct chunk of work.
I personally loved the book as it is fun, positive and tremendously useful, cannot recommend it enough.
By the way, you can ready more by Uncle Bob on the 8th Light blog.