A guide to Flow states for programmers
Tags: programming, flow, productivity, career
Published: 2018-12-02 08:32:55

---
title: A guide to Flow states for programmers
published: true
description: How to find and optimise your flow states
tags: #programming #flow #productivity #career
canonical_url: http://codingmindfully.com/keep-code-flowing-introduction-flow-programmers/
---

TL;DR:
_Flow states are optimal state of being that programmers naturally encounter. They facilitate enhanced learning, optimal productivity and a sense of satisfaction with life - therefore, they are worth being pursued. There are a number of things you can do to optimise for flow, including (1) setting clear goals (2) balancing skill and challenge (3) shortening feedback loops._

This article was first published on [CodingMindfully.com](http://codingmindfully.com/keep-code-flowing-introduction-flow-programmers/).

<h2>How to optimise your experience of life</h2>
One of the things I’m most concerned about in life is opti mising my experience. I want my work life, my free time, and my relationships to be packed full of value, meaning, and fun.

It’s a bare fact that we’re not here for long in cosmic terms -- mere decades. The earth is already billions of years old, and our modern, agricultural civilisation has only been around for tens of thousands of years.

The duration of a human life pales in comparison.

I’m not trying to be morbid here. I’m just pointing out that, since our time here is so brief, it makes sense to try to get the most out of it.

I want to live a life that is full of meaningful experiences. I want to inhabit states of being where I feel energised, useful, productive, and challenged as often as I can.

For me, that means trying to create a life where, for the most part, I can be absorbed in what I’m doing as often as possible. As a programmer, I find endless opportunities to ensure that this is the case!
<h2>Flow and code</h2>
Ask any programmer what they love about their job and inevitably the conversation will turn to flow states, even if they don’t use that terminology.

We all know the state of flow – periods of intense absorption in the task at hand, where time seems irrelevant, where problems are effortlessly solved through near-automatic application of our carefully-honed skills.

Anybody who has gotten lost in the pleasure of an all-night coding session knows what I’m talking about.

For many of us, the opportunity to enter such states is a deep part of the attraction of a career in programming.

A programming job, by its very nature, provides daily opportunities to explore flow.

For some of us, it’s something we remember fondly, something that’s perhaps disappeared from our life.

Maybe the job has changed, maybe life circumstances are getting in the way – but either way the feeling of being “in the zone” is long gone.

The good news – flow is a well-researched area. There are things you can do to optimise your life and career for flow experiences.

In this article, we’ll dig into flow and how it relates to programming. We’ll examine the conditions for flow states. As we’ll see, focused attention is essential to flow, so we’ll naturally investigate how to enhance this capacity that we all possess.
<h2>Flow state psychology for programmers</h2>
Mihaly Csikszentmihalyi (Hungarian, pronounced like Six-cent-mi-hai) literally wrote <a href="http://www.goodreads.com/book/show/66354.Flow">the book</a> on flow states.

He’s regarded as one of the world’s leading researchers in positive psychology – the deliberate creation of positive human experience.

I love <a href="https://en.wikipedia.org/wiki/Flow_(psychology)">his work</a> – it’s all about optimising quality of life.

Mihaly says that flow states are characterised by “a feeling of great absorption, engagement, fulfilment, and skill—and during which temporal concerns (time, food, ego-self, etc.) are typically ignored.”.

Sound familiar?

Ever lost an hour or three in this state of absorption while cutting some code?

Where your mind and body seem to produce things automatically, almost effortlessly?

It’s a beautiful feeling. Surfers, extreme sports enthusiasts, yogis all go looking for it.

Better yet, work on flow states has demonstrated that there are a set of clear factors that facilitate them. So, if you’re struggling to find your flow, here’s a few things you can do about it.

Let’s take them one by one.
<h3>Clear goals and view of progress</h3>
Flow is optimised when you know where you’re headed. For programmers, this sense of direction has several layers.

At a low level, this means being clear about the outcome you’re trying to achieve in the next few hours or during your work day.

This means it’s better to identify exactly what your outcome is for a coding session, rather than just diving in with no plan.

I’ll often write the goal down – this is often useful when your attention is distracted later on.

Depending on your circumstances, it might make sense to identify and list the set of classes/functions/modules that you wish to create, as well as list the tests you’d like your code to pass.

If you’re working in an agile or other task-based environment, you can use the task for goal definition. It’s still a good idea to make a physical list for when you inevitably get distracted.

That list might sound like overkill, but it actually allows you to measure progress, which is also essential for flow.

I’ve used the <a href="http://www.stevepavlina.com/blog/2014/12/do-a-full-days-work-in-90-minutes/">focus blocking</a> technique described here to define goals and track progress successfully – I’d love to hear if it works for you.

At a higher level, there’s the project or system you’re working on. Lack of clear goals or strategic direction is a flow-killer.

All of us need to feel that our work is directed towards sensible and meaningful goals. Sometimes, it’s not clear that this is the case.

Depending on your particular context, you’ll have to work out whether there’s a communication issue, or whether there’s something more fundamental about your project or job.
<h3>Immediate feedback</h3>
Flow states are characterised by immediate feedback.

Feedback is information that is used to make adjustments to a process. Appropriate feedback loops in programming provide only useful information about what your code is doing and how well it’s doing it.

One of the purest joys of programming is the opportunity to experience near-immediate feedback. The write-build-run cycle means you see the results of your efforts very quickly, and make adjustments immediately.

One of the greatest frustrations of programming is working on projects where this sort of feedback is slow to obtain.

Knowing that feedback leads to flow, here are two pieces of advice:
<p style="text-align: center;"><em>In order to facilitate flow, set up your feedback loops early.</em></p>
This is one of the many advantages of automated testing. As well as being super helpful for preventing regressions, the little red or green lights on your screen are an instant and obvious source of feedback.

If you needed more encouragement to start writing automated tests at all levels of your code, this is it!
<p style="text-align: center;"><em>If you’re having problems finding your flow, check your feedback loops.</em></p>
We all know the feeling of sitting down with an inherited codebase and trying to figure out what the hell is going on. Flow can be hard to find in these situations.

In these cases, it’s useful to examine what information you’re getting from running code.

If it’s very black-box, how can you start getting information about the system? Using appropriate filters, maybe it’s time to turn on some logging, so you’re not overloaded with information.

If you find yourself having to go through a number of manual steps to get the results of running some code, it’s time to ask yourself what you can automate. The time taken to set up and run code can seriously impact your flow.
<h3>Balance between skill and challenge</h3>
Flow states arise most naturally from the sweet spot between skill and challenge.  <img class="size-medium wp-image-259 alignright" src="http://codingmindfully.com/wp-content/uploads/2018/08/300px-Challenge_vs_skill.svg_-300x292.png" alt="" width="300" height="292" />

Too little of either, and we end up apathetic.

Too much challenge with too little skill means anxiety.

And too little challenge can lead to boredom.

Programmers are constantly learning and relearning how to balance skill and challenge.

Programming is a learning-based career. If you don’t care to learn new skills, you’re probably in the wrong job!

Getting this balance right to optimise for flow can be tricky because you’re not always in charge of your tasks, which means the challenge level might not be appropriate.

Try to take on tasks where you know you’ll be challenged, but also where you’re confident you’ll be able to complete them. Work with your team members to ensure that both conditions are met – make it clear that you’re keen to learn.

If you consistently find your lack of a particular skill is in the way, it might be time for some deliberate practice.

Another strategy I use before commencing a block of work is to research my uncertainties first. If there’s something I don’t know how to do, I look it up before engaging in a block of work. This way I avoid the Google black hole of distraction… speaking of which!
<h3>Dealing with distractions</h3>
Flow generates focused attention, and is dependent on it. Distraction is a flow killer.

Our attention is a complex and limited resource. So much so that I’ll devote a future article to it. Daniel Goleman wrote <a href="https://aax-us-east.amazon-adsystem.com/x/c/QqOVgv75rcY7_dws1mArEr4AAAFk_pXV9AEAAAFKAfJ2lco/https://assoc-redirect.amazon.com/g/r/http://www.amazon.com/exec/obidos/ASIN/B00BATG220/makithecompsi-20/ref=as_at?creativeASIN=B00BATG220&amp;linkCode=w61&amp;imprToken=r95zN81XAUo.3mvfw466yg&amp;slotNum=1">a book</a> about it.

Distractions arise from two sources -- external and internal.
<h4>External distractions</h4>
External distractions are more easily managed.

The usual advice applies -- put your phone on flight mode.

Turn off email and messaging systems.

Put your headphones on and agree with your team not to be disturbed.

If you don’t already use Leechblock or StayFocusd, consider it. They’ll help you build better surfing habits.

If this sounds impossible, be ruthless with it for a while. I guarantee you, the world won’t fall apart!
<h4>Internal distractions</h4>
Internal distractions can be trickier. They can be physical, mental, or emotional.

I have a “flow checklist” on my desk. Items one and two are “get a drink” and “go to the toilet.” This takes care of the most common physical distractions.

Mental and emotional distractions are more subtle. Our minds <a href="http://codingmindfully.com/why-this-software-developer-teaches-meditation/">naturally wander</a>.

My mind is a constant stream of memory and speculation. It’s the same for most people. It’s easy to get caught up in thought loops.

I keep a notepad (actually two -- one for work, one for my personal life) by my keyboard. As soon as I find myself worrying about something other than the task at hand, I write it down with the intention to come back to it. I find this often appeases my mind and the sense of distraction subsides naturally.

How we’re feeling can also be a big distraction. Emotions, for the most part, are preparation to take some sort of action.

If I’m having an emotional day due to some life circumstance or other, focus can be hard to maintain.

It’s possible to train your mind to stay more focused, and to learn to work with difficult emotional states. I’ve found mindfulness meditation invaluable. I find when I practice meditation more, flow naturally arises.
<h2>Conclusion</h2>
Flow is an optimal state of being, and we’re lucky as programmers that it can be a huge part of the job.

Flow states have been well researched, and the conditions to find flow are within your control. If you’re struggling to find your flow, use this checklist to see where the problem might reside:
<ul>
 	<li>Do you know what your goals and outputs are?</li>
 	<li>Have you got a clear plan to reach them?</li>
 	<li>Are you getting the feedback you require to know how you’re doing?</li>
 	<li>What’s the balance between skill and challenge for the task at hand?</li>
 	<li>Are you managing internal and external distractions?</li>
</ul>
I’m a flow junkie, I look for it in every area of my life, whether that be in my yoga practice, while writing articles like this, or during my day job of cutting code.

So tell me, what’s your flow story? I’d love to know!

Read more at [CodingMindfully.com](codingmindfully.com) - Home of the Ultimate Guide to Meditation for Programmers.