Encouraging the Wrong State of Mind for Creating Good Code
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.
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.
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.
Of course, boredom can become apathy and stress can become burnout. As with almost any high efficiency bargain, there’s a narrow line between hitting a sweet spot and falling off the cliff.
But used in moderation, boredom and stress are amazing tools for creativity.
A State of Perpetual Busyness
The problem that most developer and most companies have is that they prefer and encourage a state of “busyness”. That is to say, nothing is on fire, but there are always a few things to do.
Fixing a non-critical bug here, adding a small feature with a far-away deadline there, chatting with Fred about reducing technical debt, creating a report on the state of automation in regards to testing, helping Charlie learn that library you kept talking about, etc.
It’s understandable that most people like being somewhat busy, that way they feel like they are doing “something”, but they don’t feel overwhelmed. They feel useful yet comfortable.
As is true the case for most “balanced” states of mind, busyness feels good. But feeling good is a reason to stagnate, not to innovate. We need adversity in order to be creative, we need to feel that something’s not right in order to progress.
It’s also understandable why most companies like busyness: it gives managers a sense that all is moving forward “as planned”. The employees aren’t being “lazy” and the bosses have everything under control. The worst thing for a manager to see would be people hanging around the office doing nothing all day or people constantly putting off everything because the production servers are one step away from burning down.
This busy-yet-complacent state leads to crisis further down the line. People don’t have the time to think in advance, like they do when they are bored, and they don’t have the need to learn how to deal with and improve from extreme stress.
Humans don’t form strong bounds and good teamwork practices when they are busy. Collaboration and innovation occurs people have to collectively face a huge challenge or when they are trying to fill in dead time.
A state of perpetual busyness is harmful because it doesn’t leave you time to think of good ideas and it doesn’t force you to think of good ideas.
I’m not saying that work on a project should always oscillate between highly boring and highly stressful. But we need to start taking into account how useful these states of mind are and welcome them rather than try to avoid them at all cost.
How I Trigger Mental Hormesis
The way I try to introduce these states of boredom and stress in my work life is by getting rid of huge swaths of work in as little time as possible. Pull hard for 2 days, relax (and get bored) for the other 3.
It’s good to note that I don’t do this every week or even every month, but I do it often enough so that I don’t get complacent and I do it more often if I feel like something is “flawed” with the code but can’t quite figure out what or why.
Another good way of introducing external stressors is to work on other projects, be it inside the company, for another company, or on an open source project. This way, you are slightly overloading your work capacity for a few days or weeks and you start thinking of innovative ways to improve development on your main project, to keep stress coming from that to a minimum.
Still, especially in large companies, there needs to be a change in culture for this kind of work style to be acceptable and improved upon. In corporations, both managers and colleagues seem to prefer everyone to be in a constant state of busyness. Not doing anything “productive” for a few days is seen as lazy and overworking yourself is seen as being a try-hard, wasteful and short-sighted.
But it’s the combination of these two things that makes for the best engineers out there.