A lot is written in various places about programmer flow. It’s been called a few things: finding the flow, being in the zone, coding mode. Usually it’s mentioned when talking about programmer productivity in general, as in “get the programmers private offices, breaking their flow causes major productivity drops”, or sometimes some coder reflects “I was really in the zone yesterday when I wrote this”.
Not much is written about what the flow actually is though. Often it’s viewed as something near-magical, since even if you’re left undisturbed it can be incredibly hard to find the flow — but if you do, the results can be magical indeed.
But is it really magic? Let’s start by defining what it actually is:
Flow is the mental state of operation in which the person is fully immersed in what he or she is doing by a feeling of energized focus, full involvement, and success in the process of the activity.
To most people, focusing on something easy — sit down undisturbed and think very hard about that thing and only that thing. However, flow is something more — the feeling of energized focus and full involvement is a part of it, but the success factor is more important. You won’t feel flow unless you’re continually moving forwards.
Once we’ve understood that continual motion is a key to maintaining (and entering) flow, we can start looking at practical tips for getting into and staying with the flow. I’m not saying that these rules are going to solve all your problems, but they can get you quite a few steps on the way towards diving in with the flow.
Environments matter, but much less so than you’d think. Different people break out of flow differently and find varying difficulty in getting back into it, so find your own level here:
- Isolate yourself – it’s impossible to find the flow when continually talking to others or hearing conversations. Even if you’re sitting near other people, put your headphones on and put some music on.
- Get your equipment sorted — make sure you don’t run into any difficulties with the equipment, and that there’s nothing with it that annoys you. Small nagging annoyances can easily distract your full focus. Make sure your keyboard doesn’t glitch, make sure the editors and tools you use work smoothly, make sure you have good headphones that shut out the world around you, make sure there’s not going to be sunlight shining directly on your monitors in half an hour.
- Communicate your flow — tell people about it. When you isolate yourself it can feel hostile towards others, but trust me they’ll understand. Just tell them you’re going to be putting your headphones on because you need to focus on something.
When in doubt…
Flow breaks when you get stuck with a problem. Not having flow, it’s easy to get stuck on just about anything. These two factors are what stops many people from getting into flow, and since they’re interconnected it’s hard to break out of that loop — you’re stuck with something that’d be easy if you had flow because you don’t have it.
The good news is that this works the other way around as well. If you can manage to not get stuck and to always keep moving forwards, you’ll be in the flow before you know it.
- When in doubt, compile — often, while in the middle of writing something, you’ll run into some problem or other and get stuck. If you find yourself snagged on something for more than a few seconds, start the build. This may seem entirely unrelated to what you’re stuck on, but fact is you’re likely to have compile errors somewhere in the code you’re writing, so why not fix them now that your mind is busy figuring the problem out.This tip has two good properties. One is that you may gain insight on the problem you’re stuck on just by fixing the compile errors in the surrounding code. The second is that you keep moving, and thus you never get the same feeling of stopping what you’re doing, which can break flow.
- When in doubt, type — it’s easy to get stuck on a design problem and let that stop you from coding. However, there’s nearly always some typing to do — create a blank file for the class you’re thinking about. Fill in the file with all your template stuff that needs to be there (header guards for a c/c++ project, for instance).Now keep going — create a blank class. Type in a method signature (doesn’t matter if it’s not 100% correct) for a method you think you might need. Type in another. Create void implementations of the methods — maybe you’ll realize that you need something more, so add that in. Change things around. As you keep doing these small, seemingly mechanical tasks, you help your mind along the way by providing a framework for what you’re designing.
Again, this has the dual point of moving forwards and helping your brain activity along. Sometimes, typing something into your editor and then immediately going “no, that’s not right” can save an hour of thinking (or even more, if you lost the flow and your mind wandered).
- When in doubt, find the loose end — sometimes you’re faced with a large amount of entangled code or design and you don’t know where to start. This tends to happen when starting new sections or subsystems, where the amount of work to do is large enough to cause you to not be able to grasp the entire thing up front. Maybe you don’t see the design for the system clearly, so you stop to ponder about it, losing flow.The best thing to do in this situation is to dive into the code. Find one strand and start untangling it. There’s bound to be some part of the code where there’s a small piece you know you’ll need. Start there. When you’re done with that, not only will the amount of remaining work be smaller, you may have found new insights into the surrounding code tangle, making it easier to keep untangling.
The overall theme is quite obvious: as long as you stay isolated from the distractions of the world and keep hammering at your code, even if it’s just doing mechanical stuff, you’ve got a large chance of finding the flow.
This makes it a lot less magical, and a much easier tool to bring out. Does that mean you should always do it? No, there are certainly points where the best thing to do is to stop and make sure you’ve really thought things through properly. That’s a choice you should make actively, not one left to magical chance.
Before you know it, you’ll be the magician.