Encouraging the Wrong State of Mind for Creating Good Code

Your company is doing it and you are enabling it

You can read this article on my own blog, if you prefer that to medium.

Over the last year I’ve started noticing this strange pattern of how innovative ideas come to me when working on a project. Innovative — as in solving a problem in a creative way that makes the solution much easier to implement, much less fragile, or both.

It seem to me that innovative ideas emerge in two states of mind: bored and stressed.

I’m going to focus on how this applies to people’s professional work, rather than their hobby projects, because that’s where employees and manages shun these two states of mind most.

Boredom and stress are both, to some extent, external stressors for your conscious thinking. The simplest way to see this is to think about how you feel if you are overworked, anxious, or bored for a long time: you feel bad.

But external stressors aren’t all bad. The dose makes the poison. In recent years, medical researchers have become more and more interested in the idea of hormesis, the long-term positive adaptation of our bodies triggered by short-term, non-deadly stressors.

The best example of the hormetic effect is exercise causing a short-term raise in cortisol, but actually lowering cortisol levels overall during that day. Similarly, exercise induces oxidative stress (a factor in a host of problems ranging from dementia, to cancer to arthritis), but your body reacts to said stress by producing enzymatic antioxidant(mostly superoxide dismutase, catalase and glutathione peroxidase) , it actually leads to lower overall oxidative stress.

Other less proven examples of hormesis are short-term exposure to extremely hot or cold temperatures, fasting and even low dosages of ionizing radiation and alcohol (ethanol).

But this “what doesn’t kill you makes you stronger” principle also applies, I would argue, to your thinking. When you are in a bad state of mind, you are forced to think about getting into a good state of mind and your brain starts getting creative.

On Boredom

The benefits of boredom for creativity are probably obvious for most of you. If you have nothing to do for extended periods of time other than reading or procrastinating, ideas will start flowing through your mind.

In this context, boredom also implies that there’s no state of urgency in regards to whatever you are working on — everything is going smoothly; sure, there might be a small issue here and there, but your 8h/day job really only takes about 10 minutes a day to do.

Much like sleep, boredom allows your subconscious to take over for you, to do the heavy lifting in terms of ideas. It also allows your brain to restructure information.

Boredom is also nice in terms of allowing you time to detach yourself, it allows you to see the bigger picture. If you are focusing on a single tiny bug, your whole life becomes the parts of the code where you are tracing the bug. If you are thinking about predicting where the next tiny bug will emerge, your mind will switch to a wider perspective of the code and data you are operating on.

Furthermore, boredom provides you with a hunger to spend all that free time on something. If you are constantly bombarded with tasks, you don’t necessarily feel the need to plan a 40 hours refactoring adventure, but if you are extremely bored, finding something difficult to do might seem like a great idea.

The number of times I went from bored to “I have an amazing idea” are countless.

On Stress

One more controversial claim I will make is that stress is also a great helper in regards to creativity.

Let’s say that the project you are working on is burning, you’ve been fixing issues or adding critical features for 10 to 14 hours a day for the last 5 days.

You won’t necessarily have a “detached” view of the project, but you will be so familiar with every line and every snippet of code that you won’t need to detach yourself, because your mind can already navigate the project at any level it desires. You won’t have the energy to involve your subconscious while awake, but I guarantee you that you will be thinking about the project in your sleep.

Most importantly, you are in a situation where you are forced to think creatively, because you either find a way to make your job easier by being innovative, or you soon won’t be able to handle it. This is an uncomfortable position to be in, for sure, but your brain is made for these high-stakes type scenarios.

Many of us become creative and motivated only when we have skin in the game, when our head is on the chopping block. You might not want to do that 40 hours long refactoring, but if it’s the only way to get things running decently again and stop issues from pilling up, it will seem like the best way forward.