How To Cultivate Superhuman Focus While Writing Code

It all comes down to the doors you close


Zachary Minott

3 years ago | 4 min read

Focus is an all-too-rare commodity that many programmers yearn to develop more of.

A flow state is the suspended state of mind that many of us want but find very difficult to cultivate. It’s in this liminal space that we find ourselves lost in a void of focus — as if all the knowledge in the world is channeled into our fingertips as they glide effortlessly across the keyboard.

With focus, architecting becomes easy. Coding becomes easy. Debugging becomes easy. Innovating becomes easy. Every problem, at that moment, seems easily resolvable.

Yet, as I said before, such a state is rare. Simply telling yourself you need to focus hardly has an effect beyond the five minutes your willpower provides you.

So the golden question is “How does one instill a focused state that allows them to work deeply and effortlessly within that mythical flow state?”

An Easy Place To Start

In his book On Writing, prolific and famous writer Stephen King says his #1 piece of advice to cultivate focus is simple:

“Close the door.”

Now you can take the conventional route and discover your flow state by engaging in work that’s just a tad outside your skill level, but as developers with randomized task lists that vary in levels of difficulty, this technique is hard to follow on demand.

King’s advice to “close the door” parallels the idea of “wiring in” that we see in the movie The Social Network. If you haven’t seen the movie, simply picture a programmer with big headphones completely absorbed in the work he’s doing. Just the programmer and the screen in front of him, the world silenced around him as if those two were the only entities in existence.

Although you can take this advice literally, it was delivered with the intention to be taken symbolically.

The Many Doors You Can Close

Our minds are easily distracted and pulled in a plethora of directions. It’s hard to narrow that focus when your environment isn’t working to your benefit.

As developers, we’re plagued by the pull of different tasks that are ambiguous in importance. We’re boggled by the countless tabs open on the same screen.

We’re distracted by the pings and vibrations of notifications from our phones, emails, and communication channels like Slack — not to mention the attention that’s stolen from coworkers and meetings.

All of these things easily make us succumb to the negative throttling of context switching — the act of switching between different contexts frequently. According to psychologist Gerald Weinberg, context switching can kill somewhere between 20-80% of our productivity.

The amount of productivity that’s killed is determined by the number of contexts (tasks) that you’re switching between.

The best way to mitigate the detriments of context switching is by first and foremost finding all of the doors you can close. This is important because it limits the potential of any distraction within your environment. That way, you only have a single task to focus on at a given time. A task that you can provide your undivided focus to.

Aside from literally closing your door (which is extremely effective, by the way), you can look into cleaning up your environment:

  • Create tab groups in Google Chrome so that you know exactly where every single item you need to focus on belongs. A research group, a task group, and a communication channel group can be some ideas. Another good Chrome extension that is useful for cleaning up your workspace is OneTab, an extension that dilutes all of your tabs into a single tab to eliminate any potential distractions. This way, you choose what you need to focus on at a given time.
  • Put on some headphones and play some ambient music. This allows you to drown out any external distractions. Also, you can associate the simple act of putting on your headphones with the urge to focus on what’s in front of you. This can catalyze productivity.
  • Place your phone in another room and schedule a time of day to check emails and your phone. The simple act of placing your phone in another room allows you to eliminate any impulse to constantly pick it up. Several studies indicate that as long as your phone is visible (face down, face up, or out of sight but within reach), it still serves as a huge productivity killer. Simply place it out of sight and out of your immediate reach, and you might find that you’re better for it.

Focus comes down to simply managing all potential distractions. I know, it sounds far easier than I’m making it out to be, but that simple intention to clean up your workspace and close all the doors that are open to letting in distraction can go a very long way.

Remember, minimize what you’re paying attention to at one given time to maintain and grow your focus. One thing at a time. That should always be your goal whenever you sit down to work.


Created by

Zachary Minott







Related Articles