Blake Smith

create. code. learn.

»

clean code creates opportunity

Why is it that good programmers love clean code? Why do we spend so much time talking about it, writing about it, heckling our co-workers for not writing more of it?

Vision

Structured Communication

We like test driven development because it gives us fast feedback about our code. It’s our way as programmers to have the code constantly talking back to us. Test driven development is about trying to keep our brain and the computer in sync. This is how the machine talks back, and if we listen and take action, our systems will be better for it. It’s easier to see all the parts of the program when all the parts are clearly communicating how they operate.

The same can be said about clean code. If you’re working with clean code, the system will seep into your brain easily. You’ll see the floor swept, the books on the bookshelves neatly arranged, and counters wiped clean. You’ll find that you have space to move around, and space to work and play in. This is an environment for life and creativity. On the other hand, if you’re working with dirty code, you’re going to spend a lot more effort trying to cram the system design into your head. You’ll see unwashed clothes and dirt on the floor, the bookshelves will be covered in dust and debris, and the counters sprinkled with food crumbs. This is not the place to do your best work.

Unrealised discoveries

It’s difficult to build something great without taking the right first step. If you’re a chef, it’s hard to create a 7 course meal when the sink is stacked to the ceiling with dirty dishes. All the pieces have to be cleaned and put into their correct place before you can begin to work well. If you start with dirty dishes, you’re going to get some weird tasting food. Dirty code is like cooking with dirty dishes: new features just aren’t going to come out right if the code can’t be tidied up and organized first.

Clean code creates opportunity. Clean code creates vision; the ability to perceive and know what action must be taken next. Clean code creates a vacuum that your brain is able to imagine being filled. When you’re working with dirty code, you see mold and decay and dark alleys. The code will stop pointing you to the scenic pastures and will instead sink you into a dark bog. If you can’t do the work to make your code clean, it will be that much harder to see where the code ought to lead you. Clean code will not create innovation, clean code will simply create the opportunity for innovation. It will open up doors you didn’t know existed.

What new discoveries are in your codebase? Are the ideas buried below mounds and mounds of caked mud? Or are your ideas floating on the surface of a pond of shimmering water, waiting for you to scoop them up with your net?


about the author

Blake Smith is a Principal Software Engineer at Sprout Social.