Rules of Programming: Keep Focus
Being in the zone and having a good flow when programming, is more of an exception, rather than a rule. However, you can change that by minimizing the number of distractions.
Kill your email and your Twitter client for a while. Use headphones, everybody will see you're busy.
The better your flow is, the better your code will be.
Rule #19 of programming:
Keep Focus