For me, being “in the zone” is very important if I want to get any significant amount programming done. It’s commonly said that it may take 30 minutes to get to a state of concentrated focus, but a mere 30 seconds of distraction to lose it.
I’ve been trying to find a ways of optimising how I get into such a zone, and, while this is totally un-scientific, here’s 3 things that work for me. Why not see if they’ll work for you?
I have a big glass of water nearby at all times. Humans need water, and I’m no exception. Neither are you. Probably.
Silence / Music
Sometimes I work better in silence, and other times with music.
Living in halls, it’s not really an option to ask everyone to be quiet, so I tend to don a pair of over-ear headphones, plugged into nothing. You could also try very low-level white noise, or an ambient sound like the sea.
When it comes to music, no lyrics is the single most important factor. If I’m coding, the last thing I want is to be hearing of someone else’s troubles. I (like Notch) favour minimal house (Trentemøller), ambient/breaks (Hybrid Soundsytem 01) or drum & bass. Deadmau5 is good too.
This may be a strange one, but if I really want to focus on some code then the lights are going off. Jeff Atwood has written some great stuff on this, and I pretty much follow his advice. Light behind the screen, ambient lights off. The strip lighting I have (and wish I didn’t) is absolutely the worst kind and is also in the worst possible place, directly behind and above my head, so it has to go off. My Macbook’s backlit keyboard helps too.
I hope you get something from what I’ve discovered to help you focus for a hardcore code session. I have a whole different set of criteria for design work, and I’ll cover them another time, perhaps.
Thanks for reading!