Explaining Productivity
April 18th, 2008 by JonTrying to explain why a programmer is productive one day while being completely unproductive the next day can sometimes be a futile exercise. The lazier amongst us won’t even bother to explain our unproductive days, citing “I was tired” or “I just didn’t feel like coding” as excuses. Excuses, excuses.
Today, I’m not going to talk about the bad days. I’m going to talk about the good days, the days when you feel energized and productive because you got a week’s worth of quality work done on one night. What’s going on there, and what makes it happen?
Coding is a mentally demanding activity. I’m talking about real coding in which you are tackling a problem that you haven’t encountered before. For your coding session to be productive, there are a few required conditions, in my opinion.
- No Distractions. Distractions are the bane of most programmers. If you aren’t isolated from the outside world, it’s very hard to concentrate and get into that super productive mode, and even if you reach that state of productivity, it’s very easy to snap out of it. This is why programmers are generally most productive in the mornings and nights - simply because that’s when things are quiet.
- Have a Game Plan. Some people can leap straight into a problem without any preparation, but for the rest of us, it’s good to have a rough outline of what you want to do. Nothing terribly detailed, but just something to keep you on track.
- Eat, Drink and Sleep. Please, please don’t code on an empty stomach, and don’t code if you are sleepy. It doesn’t work, and it’ll bite you back when you realize that you made tons of progress and introduced tons of bugs in the process. Likewise, if you aren’t nourished, your brain is not going to be able to reach that magical state, and you’ll feel like a car without gasoline if you attempt a coding session.
Coding is like sleep.
With those three conditions in place, you can begin coding, but what actually happens? Coding is much like sleep in the sense that there are various stages of sleep, and like sleep, your goal is to get into the deepest stages, and those are the stages in which you become optimally productive. Like sleep, you tend to lose awareness of your surroundings and focus entirely on the problem at hand, and for lack of a better word, some bottleneck in your mind disappears, and you begin progressing without slowing down or pausing. You just keep moving forward, feel good about it, and continue until the problem is solved.
You must load in the problem.
How do you get into this state? My theory is that to reach this state, your mind has to “load” in the entire problem that you are tackling, much like a computer that’s loading a program into memory. Your memory capacity is limited, but once you load that entire problem in, then you can begin processing it. This process takes anywhere from 10 minutes to an hour depending on the person and the problem. Once the problem is loaded in, you begin processing it, and while doing it, your mind “optimizes” things along the way (think like a JIT compiler), so you begin to process things faster and faster until you reach that optimal state in which nearly nothing can stop you.
Distractions = Preemptions
Now what about those distractions? Distractions can be likened to preemptions, interrupts, or whatever you’d like to call them. All of a sudden, you switch gears, you load something entirely different into your “memory”, and if the distraction is bad enough, it may cause you to lose your focus, equivalent to a page flip in computing. Once that happens, you have to waste time reloading the “problem” into “memory” before getting back into your relative state of programming nirvana.
While this analogy may sound strange, I find that it pretty nicely explains why you’re productive on some sessions, what you feel when you’re productive, and to everybody else out there, why we programmers hate distractions. Next time you distract a programmer who’s absorbed with a problem and get an angry glare from him or her, this is why.
What are your thoughts on this topic?