This is motivated by Jacques Mattheij's recent blog.
Recently I have been having amazing productivity in my work and have been hitting the "zone" quite regularly. Here is what I think gets me there. The big difference with Jacques's blog is that these are mostly internal factors:
1. Inspiration: To be in the zone I have to be reasonably inspired. Since I primarly build for the web, I get inspired by other startups and design firms that come up with fantastic work. 37signals is a regular source of inspiration, so are my customers who are using my product. Those few occasions when my customers allow me to access their account (for fixing bugs), I am totally impressed by how deeply they are using the application and its a source of high and inspiration to do better.
2. Confidence: Since I have been writing code for over 15 years now, I have built a reasonable skill set. A new features / simplifications seem within reach. Even if I am refactoring code, there is a new "level" of confidence in the way I go about things. The places where I break the functionality, or the way I write Object Oriented code is very different from what I used to do even a year back. Now I don't have second thoughts on whether this is the "right" design. After years of failing with bad design, I think I have learnt from my mistakes.
3. Stamina: After a project (or a sub-project) is done (like done-done), you realize that atleast 30% is remaining. At first, I would walk away to another project, but now I realize that that 30% is the killer in terms of usablity and making it high quality. So putting that extra-bit to make it really polished is also helping me higher satisfaction and keeps me in the sweet-spot where I am constantly looking to improve.
4. Inner Peace: For the last couple of years, the lack of success of my startup was bothering me deeply. I would be extremely stressed about the fact that I have not been successful compared many others. This anxiety would lead to bad decisions about strategy, recuritment and everything in general. Recently, I went through a meltdown and decided that things must change. It was very hard process but at the end of it, I think I unlocked another level of the "zone". I think I have made peace with myself and my pace of doing things. I let things come to me rather than going after them. I think that really helps me when I am writing code.