✅ Easily Write Better Code With 7 Tips to Get in the Zone
Tags: productivity, codequality, motivation, adventofcode
Published: 2019-10-04 18:53:10

# What's Flow?

Flow has been described as a mental state where you're able to become fully immersed, focused, and enjoy the task at hand. 

It's that weightless feeling of humming along with perfect productivity when just doing the work is intrinsically motivating, without the need for additional rewards or using consequences as motivators.

---

**Flow is also described as being “in the zone.”**

---

Some of my best code was written in this zen-like state while solving challenging problems. I loved solving last year's [Advent of Code](https://adventofcode.com/), a coding challenge with a puzzle every day in the month of December. I was so deep in concentration that time felt like it came to a stop.

# Repetition Is the Enemy of Flow

Unfortunately, the longer we code, the likelier we are to find ourselves working on mundane tasks, solving the same problems over and over again.

When our work becomes repetitive and routine getting in the zone might feel daunting. It might feel difficult to get into and stay in the zone when the challenges of the work we're doing don't align with our skills. This scenario can result in feeling apathetic, bored, or even anxious.

# Skill Versus Challenge

![](https://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Challenge_vs_skill.svg/300px-Challenge_vs_skill.svg.png)

Take a look at the guide above. You'll notice that apathy, or a lack of interest in the task at hand, can be caused by a problem that's too easy even for someone inexperienced.

If the problem is too easy for our skill level, we might quickly become bored with it. Or worse, when the problem is too hard than our perceived level of skills and abilities, it might cause a heightened sense of anxiety.

---

**Flow happens at the intersection of challenging work and a high skill level.**

---

# Get Back in the Zone

How can we use this knowledge to our advantage?
By adjusting the ratios!

Is the problem is too easy? *Move towards flow by increasing the difficulty.*

Is the problem is too hard? *Move towards flow by leveling up and learning new skills.*

---

**We need to be doing challenging work while feeling like we have the skills to achieve it.**

---

Sounds easy, right? Well, unfortunately, chances are that the conditions you find yourself in just aren't ideal for getting in the zone most of the time.

Luckily, while *we can't* force a state of flow, *we can* make changes to how we work to increase the likelihood that we'll achieve it.

To understand how we'll review the seven conditions for flow as proposed by [Owen Schaffer](http://humanfactors.com/whitepapers/crafting_fun_ux.asp).

# 7 Steps to Get Back on Track

## 1️⃣ Know What to Do

Knowing what to do may seem obvious, but we've all sat down and opened our editor to work on a new feature or to fix a bug without having a clear idea of what we need to do next.

You *think* you can just wing it, but your goals need to be clear and achievable to help you get in the zone.

---

**💡 Tips**
* *Identify what success looks like for your working session before you start.*
* *Have a specific idea of what you need to accomplish.*

---

## 2️⃣ Know How to Do It

If you don't know enough to finish the task at hand, you may start worrying. Fear of failure can trigger anxiety.

Success in achieving flow involves making the problem achievable.

---

**💡 Tips** 

* *Increase your skills with reading and research until you feel like you know enough to try solving the problem again.*
* *Try breaking down the problem into smaller more manageable pieces.*

---

## 3️⃣ Know How Well You're Doing

While you're solving a problem, feedback about how well you're doing needs to be both clear and immediate.

Luckily, we can easily set up our development environments to signal success or failure.

Are you a front end developer? Aim to have a working prototype as quickly as possible. Set up auto-refresh to see your work-in-progress. It'll allow you to move the project along in real-time.

Another great way of getting immediate feedback is by writing unit tests or practicing test-driven development (TDD). 

You don't have to stick with every rule of test-driven development to see the benefits. Try to write a few unit tests, and run them frequently. If your test suite is fast, you can even have your tests run every time you save a file.

![Sea of green for passing tests](https://thepracticaldev.s3.amazonaws.com/i/an6ht2d78ee4b9oybpsa.png)

---

**💡 Tips**
* *Work in small increments and test your work frequently.*
* *Write and run tests to immediately see immediate feedback on your code.*

---

## 4️⃣ Know Where to Go

Athletes are more likely to achieve flow where they know where to move next.

The same paradigm is also vital to programming.

Pausing frequently to figure out what to do next can be increasingly distracting.

Before getting started, create a detailed plan of attack for how you plan on solving your problem or implement your feature.

Make sure your tools help you do your job seamlessly and effectively. As a Python developer, I'm a huge fan of the [Python Extension for VS Code](https://marketplace.visualstudio.com/items?itemName=ms-python.python&WT.mc_id=flow-devto-ninaz) in combination with iTerm2.

Learn those keyboard shortcuts you've been putting off, adopt more command-line tools if that fits your flow, and dial back on interruptions.

---

**💡 Tips** 
* *Break up tasks into small, clear, concrete actions and create a detailed to-do list.*
* *Dial in your tools so they're not a distraction.*

---

## 5️⃣ High Perceived Challenge

The work that you're doing needs to be sufficiently challenging to keep you interested and engaged. 

If you're highly skilled, but the task is too easy, you're likely to slip into boredom, or worse, apathy.

What can you do if you're stuck in this situation? Don't aim to overcomplicate, but figure out ways to teach yourself new things while you work.

Is it possible to try a new design pattern or apply a different architecture to this problem? Can you use an unfamiliar feature in a programming language you know? Would it make sense to learn an entirely new programming language to achieve your goals easier?

It can be challenging to raise the perceived difficulty of boring, mundane work. If you can find a way to make your work more challenging, you'll be rewarded with a higher chance of slipping into the zone.

---

**💡 Tips** 
* *If the task is too easy, find new ways to learn while you work.*

---

## 6️⃣ High Perceived Skills

You've already learned that if you're too highly skilled for the task at hand, you're likely to become bored with it. If you're not experienced enough, you might feel anxiety or a fear of failure.

But what if you *do* have the skills, but you just don't know it? That's imposter syndrome, and it's a common issue affecting developers of all levels.

In the tech industry, it can feel like there's always someone, better, smarter, more confident, and more eloquent than you. It can make you feel smaller, like a failure, or that you'll never live up to your own expectations.

Getting lost in the whirlpool of comparing yourself to others is a sure-fire way to cause doubts and feel bad about yourself. Try to take an honest inventory of your skills, and celebrate the things you *do* know instead of feeling bad about the things you *don't*.   

If you know more than enough to get the job done, but if you don't have confidence in yourself, you'll have a much harder time getting in the zone. You'll need to *believe* that you're skilled enough to tackle the challenge.

---

**💡 Tips** 
* *If you think you might be suffering from imposter syndrome, read [suggestions for how to beat it](https://www.fastcompany.com/40421352/the-five-types-of-impostor-syndrome-and-how-to-beat-them).*

---

## 7️⃣ Freedom from Distractions

In today's world full of notifications vying for our attention, freedom from distractions may feel like an impossible goal.

Unfortunately, you're making it harder to get in the zone by constantly checking your phone, social media, or other distracting websites *(\*cough\* reddit, YouTube, hacker news \*cough\*)* while you're trying to work.

Avoid distractions by blocking sites, keeping your phone in another room or in a drawer, or even turning it off completely. Thankfully, there are amazing free tools to help!

* **For the web:** browser plugins block distracting websites, such as StayFocused for Chrome and Leechhblock for Firefox.
* **On mobile:** there's a mobile app for iOS and Android called Forest that helps you train your attention.
* **On desktop:** a favorite for blocking distracting websites on my Mac is the 
[SelfControl App](https://selfcontrolapp.com).


![Screenshot of the self control app](https://thepracticaldev.s3.amazonaws.com/i/7dx1ljdc0jn28brjd1vc.png)

---

**💡 Tips**
* *Minimize distractions to achieve a productive work session.*

---

# Write Better Code in the Zone

Research has shown that working in the zone has tremendous benefits. It can increase your sense of achievement and overall satisfaction. It can make mundane tasks seem more fun, and more importantly -- it can get you more excited about solving challenges.

While there's no guaranteed way to force yourself into being in the zone, the tips above should help you achieve that ever-elusive state of flow to help you do your best work.

If you have thoughts on working in flow, please discuss below or reach out to me on Twitter at [@nnja](https://twitter.com/nnja).

---

<sub>*Note: a version of this article was originally published on [The Pastry Box Project](https://the-pastry-box-project.net/nina-zakharenko/2018-february-14).*</sub>

---

Lastly, if you'd like to know more about the topic, make sure to watch the seminal TED talk by Mihály Csíkszentmihályi.

YouTube: {% youtube fXIeFJCqsPs %}