Product Crafter Emilio Carrión
English
Spanish

Coding is like cooking

You have to keep the kitchen clean

Developing software is, in many ways, akin to cooking. You follow a series of instructions and best practices called recipes to take a set of ingredients and create something new. And, just like when you cook, developing creates waste that needs to be cleaned up as you go.

When the kitchen gets dirty

Imagine you’re in your kitchen, preparing dinner. Today you have craved that dish that you like so much but that is very elaborate to make. Since you had part of the afternoon free, you decided to treat yourself and cook it.

You start with the cutting board, then you go on to the mixer, the pans, the pots. Little by little, you use and dirty each of the tools you have. Flour here, sauces there, everything is covered in food.

And, depending on the type of cook you are, two things can happen.

If you’re the type of person who likes to keep everything tidy and clean, you’ve probably already started cleaning your pots and pans as you’ve been using them. You’ve been picking up, scrubbing and putting away everything you used to keep the kitchen tidy.

On the other hand, you can be the type of person who is not so tidy (I am one of those), who has been using and leaving lying around the saucepans and spoons full of stains that now occupy a large part of the countertop. However, you have been left with a delicious meal. You’re satisfied with the work. Now it’s time to pick up everything while the food rests. You clean and put away what you’ve used and leave the kitchen.

When you don’t clean it

Despite what you might imagine, both styles of cooking are fine. Everyone has their own way of doing things and the result has been the same: a well-made dinner.

The next day you arrive again (no matter what type of cook you are) and the story begins again. Pots, pans, another well-made dinner.

However, there is a third type of cook.

Imagine you’re the messy type, but at the end of your feat you make a very serious mistake. You leave without picking up and cleaning the kitchen. You leave everything in the middle full of food scraps.

Although you leave just as happy, because at the end of the day the result has been the same: a well-made dinner.

When you come back to it

The problem comes when you go back to the kitchen the next day. Just the day your parents come to dinner, everything has to be perfect.

You arrive at the kitchen and find the mistake. You curse your self from the day before for a moment and start cleaning up.

As you pile pots and pans under the faucet, you realize something important. By leaving the food scraps there all day they have dried out and you are having too much trouble cleaning them, not even with hot water. You look at the clock. You don’t have time, your parents are just arriving. You can imagine your mother’s face when she sees the panorama.

If you had cleaned the day before, you wouldn’t be in that situation.

Cooking is like programming

Well, developing software is the same, as funny as it sounds.

When we code, we often take shortcuts. We do things quickly to get features out and validate our product. Along the way, we generate waste and dirty our code just like we do with our kitchen.

This disorder often manifests itself in the form of technical debt and accidental complexity. It’s not bad on its own, though, it’s a price we pay to develop in a more agile and iterative way. This is what we can call prototyping code.

The problem comes when you act like the third type of cook, who generates waste and chaos and then leaves the kitchen without looking back. When you go back to that code that you haven’t cleaned, you realize what a big mistake you’ve made. The sprint is upon you and your team is knocking on the door expecting to see the new features finished. You, in the meantime, are still cleaning up the mess you left there the last time you were in that part of the code.

For this reason, we have to be aware of the debt we generate and we have to act like the first two types of cooks. We can be more or less orderly from the start, until we have our dinner done, that’s not the problem. The key is that, after we have finished, and before running out of the kitchen, we have to review our work environment and leave things more or less tidy.

That way, the next time we show up, we won’t spend a week understanding and cleaning up code to implement the new changes.

By doing that we will be turning our prototyping code into productive code that can survive being changed in the future.

So the next time you cook, or the next time you code, keep in mind to clean up before you finish and leave. The self of the future will be grateful.

TL;DR

Imagine you’ve cooked a delicious dinner, but when you’re done, you’re leaving the kitchen in a mess. The next day, when you need to use it again, you’re faced with chaos and an even more arduous task: cleaning up dried food and abandoned utensils.

The same goes for code. Often, in our eagerness to quickly finish a task, we leave code messy and full of shortcuts. This may work temporarily, but in the long run, we’ll go back to that code and find ourselves struggling with the mess we’ve created.

It’s essential to spend time cleaning up and organizing our code before moving on to the next task. In doing so, we turn our prototyping code into productive code that can be easily maintained and modified in the future.

So the next time you find yourself finishing up a development task, remember the importance of cleaning up before you go. Your future self will thank you when you need to work on that code again.