Optimising your experience of life
\n\n
One of the things I’m most concerned about in life is optimising my experience. I want my work life, my free time, and my relationships to be packed full of value, meaning, and fun.\n\nIt’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.\n\nThe duration of a human life pales in comparison.\n\nI’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.\n\nI 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.\n\nFor 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!\n\n
Flow and code
\n\nAsk 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.\n\nWe 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.\n\nAnybody who has gotten lost in the pleasure of an all-night coding session knows what I’m talking about.\n\nFor many of us, the opportunity to enter such states is a deep part of the attraction of a career in programming.\n\nA programming job, by its very nature, provides daily opportunities to explore flow.\n\nFor some of us, it’s something we remember fondly, something that’s perhaps disappeared from our life.\n\nMaybe 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.\n\nThe good news – flow is a well-researched area. There are things you can do to optimise your life and career for flow experiences.\n\nIn 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.\n\n
Flow state psychology for programmers
\n\n
Mihaly Csikszentmihalyi (Hungarian, pronounced like Six-cent-mi-hai I’m told) literally wrote the book on flow states.\n\nHe’s regarded as one of the world’s leading researchers in positive psychology – the deliberate creation of positive human experience.\n\nI love his work – it’s all about optimising quality of life.\n\nMihaly says that flow states are characterised by “a feeling of great absorption, engagement, fulfillment, and skill—and during which temporal concerns (time, food, ego-self, etc.) are typically ignored.”.\n\nSound familiar?\n\nEver lost an hour or three in this state of absorption while cutting some code?\n\nWhere your mind and body seem to produce things automatically, almost effortlessly?\n\nIt’s a beautiful feeling. Surfers, extreme sports enthusiasts, yogis all go looking for it.\n\nBetter 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.\n\nLet’s take them one by one.\n\n
Clear goals and view of progress
\n\nFlow is optimised when you know where you’re headed. For programmers, this sense of direction has several layers.\n\nAt 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.\n\nThis means it’s better to identify exactly what your outcome is for a coding session, rather than just diving in with no plan.\n\nI’ll often write the goal down – this is often useful when your attention is distracted later on.\n\nDepending 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.\n\nIf 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.\n\nThat list might sound like overkill, but it actually allows you to measure progress, which is also essential for flow.\n\nI’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.\n\nAt a higher level, there’s the project or system you’re working on. Lack of clear goals or strategic direction is a flow-killer.\n\nAll 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.\n\nDepending 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.\n\n
Immediate feedback
\n\nFlow states are characterised by immediate feedback.\n\nFeedback 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.\n\nOne 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.\n\nOne of the greatest frustrations of programming is working on projects where this sort of feedback is slow to obtain.\n\nKnowing that feedback leads to flow, here are two pieces of advice:\n\nIn order to facilitate flow, set up your feedback loops early.\n\nThis 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.\n\nIf you needed more encouragement to start writing automated tests at all levels of your code, this is it!\n\nIf you’re having problems finding your flow, check your feedback loops.\n\nWe 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.\n\nIn these cases, it’s useful to examine what information you’re getting from running code.\n\nIf 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.\n\nIf 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.\n\n
Balance between skill and challenge
\n\nFlow states arise most naturally from the sweet spot between skill and challenge.\n\nToo little of either, and we end up apathetic.\n\nToo much challenge with too little skill means anxiety.\n\nAnd too little challenge can lead to boredom.\n\nProgrammers are constantly learning and relearning how to balance skill and challenge.\n\nProgramming is a learning-based career. If you don’t care to learn new skills, you’re probably in the wrong job!\n\nGetting 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.\n\nTry 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.\n\nIf you consistently find your lack of a particular skill is in the way, it might be time for some deliberate practice.\n\nAnother 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!\n\n
Dealing with distractions
\n\nFlow generates focused attention, and is dependent on it. Distraction is a flow killer.\n\nOur 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.\n\nDistractions arise from two sources — external and internal.\n\n
External distractions
\n\nExternal distractions are more easily managed.\n\nThe usual advice applies — put your phone on flight mode.\n\nTurn off email and messaging systems.\n\nPut your headphones on and agree with your team not to be disturbed.\n\nIf you don’t already use Leechblock or StayFocusd, consider it. They’ll help you build better surfing habits.\n\nIf this sounds impossible, be ruthless with it for a while. I guarantee you, the world won’t fall apart!\n\n
Internal distractions
\n\nInternal distractions can be trickier. They can be physical, mental, or emotional.\n\nI 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.\n\nMental and emotional distractions are more subtle. Our minds naturally wander.\n\nMy 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.\n\nI 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.\n\nHow we’re feeling can also be a big distraction. Emotions, for the most part, are preparation to take some sort of action.\n\nIf I’m having an emotional day due to some life circumstance or other, focus can be hard to maintain.\n\nIt’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.\n\n
Conclusion
\n\nFlow is an optimal state of being, and we’re lucky as programmers that it can be a huge part of the job.\n\nFlow 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:\n\n
- \n
- 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?
\n
\n
\n
\n
\n
\n\nI’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.\n\nSo tell me, what’s your flow story? I’d love to know!