This item in Slashdot really struck a chord with me, if you’ll forgive the pun:

..To me, programming is really the ‘last mile’ to getting something done. When I do the planning and specifications, I go on lots of walks, take lots of time with my wife, and really do as little work in front of the computer as possible. The more I plan (in my head, on paper, on a whiteboard) the less I program; and all of my rituals are to that end.’ His ritual goes like this: ‘Before sitting down to a coding session, he gets a big glass of water, takes everything off of his desk, and closes out all programs and e-mail, keeping open only his code editor. The office door is shut, and some sort of music is playing (‘typically an instrumental only… (Issac Kelly, Lead Developer at via

I don’t have any rituals, but I completely agree about planning things in your head and staying away from the computer while doing so (although playing games can also be helpful). I too like to go on walks with my wife (around the rugged Orkney coastline) or read or even go to the pub and speak to other people. All grist to the mill in some strange indirect way. My preferred music while programming is also instrumental: Underworld is the favourite. Choral music is good too, especially when it’s something like Joby Talbot’s Path of Miracles or Faure’s Requiem.