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.
How to optimise your experience of life
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!
Flow and code
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.
Flow state psychology for programmers
Mihaly Csikszentmihalyi (Hungarian, pronounced like Six-cent-mi-hai) literally wrote the book 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 his work – 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.”.
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.
Clear goals and view of progress
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 focus blocking 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.
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:
In order to facilitate flow, set up your feedback loops early.
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!
If you’re having problems finding your flow, check your feedback loops.
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.
Balance between skill and challenge
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!
Dealing with distractions
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 book about it.
Distractions arise from two sources -- external and internal.
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!
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 naturally wander.
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.
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:
- Do you know what your goals and outputs are?
- Have you got a clear plan to reach them?
- Are you getting the feedback you require to know how you’re doing?
- What’s the balance between skill and challenge for the task at hand?
- Are you managing internal and external distractions?
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 - Home of the Ultimate Guide to Meditation for Programmers.