The Mental House of Cards
I read an article just now that opened my eyes a little bit. Nothing in the article was technically new information for me but the perspective was. The article explains that programmers often love to work at night because there are less distractions, being slightly tired makes it easier to focus on a single task, and staring at a bright screen delays your sleep cycle for a while.
The part that really resonated with me was the analogy that was made about how badly interruptions break a programmer's workflow and why programmer's get so annoyed when they get interrupted.
Working on large abstract systems involves fitting the whole thing into your mind – somebody once likened this to constructing a house out of expensive crystal glass and as soon as someone distracts you, it all comes barreling down and shatters into a thousand pieces.
This analogy perfectly describes what happens to me constantly throughout the day. I take on as many small tasks throughout my work day as I can. This way I can complete as many bite-sized tasks as possible between the inevitable barrage of interruptions during the day. I've always done my best work when I'm alone without worry of interruption. My wife usually goes to bed before me so I hang out with her until then, but once she's sleeping soundly that's when the actual work begins. I'm free to start building my mental house of cards with very little chance of interruption; even the pets are usually asleep by this time. The world is mine for a few productive hours.
People who don't write code for a living don't often understand just how much concentration is required to maintain a mental abstraction of the application you're designing. Of course charts, graphs, and data sheets all help to offload some of that onto a tangible medium, but the true model of the application always lives in the programmer's head. This ability to conceptualize an application within my head is something I quite enjoy. It's almost like a form of meditation. Not at all unlike meditation, it really sucks when someone bursts into your bubble of concentration.
At my job I consider myself and maybe one other person to be passionate about writing code. Because of this, we are the two most sought after developers in the office. We get bombarded with questions from our colleagues, even before they ask Google most of the time. I'm not complaining about this at all; in fact, I really love sharing my knowledge with others and teaching them how certain things work. If I didn't enjoy it then I would never have been able to maintain this blog. Despite the fact that I do love answering my colleagues' questions, I still have my larger tasks to complete. Without the ability to tune out the world and dive into my concentration bubble it becomes really difficult to get any real work done.
After making this realization today I can see it was only natural that someone like myself would slowly migrate larger tasks into the evening hours. I've always been a little annoyed at myself because I felt like a lazy procrastinator. When you put things off until the end of the day and then work into the late hours of the night it becomes really easy to think that you are torturing yourself because you procrastinated. It never really crossed my mind that working at night was actually a natural symptom of simply being an effective developer. The decision to do a lot of work at night was definitely an unconscious one for me. There was never a point when I said to myself that night time was the time for me to get my work done.
Now that I understand some of the fundamental reasons why I behave that way I don't feel quite so bad about putting off larger tasks until the end of the day. I'd still like to find better ways to organize my time and see if I can find parts of the day where I can tune out the world and avoid interruptions, but at least now I can feel better about some aspects of my workflow that I previously viewed as lazy flaws.