I've had a lot of different work habits over my career, mostly because of internal psychological factors and external work circumstances. What I've learned from all the variation is that when I encounter a moment of uncertainty and doubt, my brain wants to decide between two choices:<p>- relaxing and taking a web-surfing break (Facebook, HN, national news) until the uncertainty resolves, or<p>- gritting my teeth, amping up the intensity, and blasting through to the right resolution while heavy metal music wails in the background.<p>I think this is because I can't face the possibility that I'm actually having trouble. Programming is easy! I'm smart! I have to be, because I'm not good-looking enough to get away with being a moron who doesn't always know what to do next, who actually has to think when he writes code. What's the point of being alive if you have to be someone like that, both ugly and stupid?<p>Yes, my brain thinks a lot of strange and stupid things when I'm not paying attention and correcting it.<p>Neither of the choices that my brain sees as exhaustive alternatives is correct. The best thing to do is relax, tell myself that programming is sometimes hard and it's okay if I need a few minutes to figure things out, and keep working on the problem even though I'm confused. For most of my life I had to be either unusually excited and happy or under some kind of threat, such as a deadline or an upcoming test, before I could bring myself to concentrate on a task that I didn't find easy. Now I do it every day.<p>What's interesting is that the techniques I use to calm down my mind while it's freaking out over the uncertainty are exactly the techniques I use to keep my mind calm while I meditate: posture, breathing, awareness of body tension, and awareness of my mental states. I also analyze my thoughts and feelings just like I do in insight meditation. Zen coding, indeed!