It seems to me that the stronger my focus, the more productive I am when coding.
However it is very hard to remain tightly focused. So my programming productivity swings wildly as does my focus. I am trying to become more productive when I code, so I'm trying to train myself to remain focused for longer.
I'm interested to hear the thoughts of other people. How strong is your focus when coding? Do you get long stretches of focus and productivity? Or do you keep losing focus and having to work to bring it back?
Also, how old are you? I'm interested to know if it's easier to focus on coding when you are younger. I'm 45.
I'm 28. My focus sucks overall, but a recent improvement I've made is the type of music / noise I have while working. I switched from music I really enjoy and tend to sing/hum with, to electronic music with little to no vocals and upbeat tempos. My mind focuses less on the words and music, and allows me to think more about what I'm doing.
I've also tried some white noise creators, like this one for coffee shop sounds: http://coffitivity.com/ Personally the techno music works better, but you may be different.