I can't say I am a good programmer but I've been earning money for programming last decades. I've thought I was born for programming and people said I was very good at it - at some point.But after 10 years of programming, I feel my programming efficiency is not as good as others. Of course, CS education is way better now and many young programmers are smarter than me. But one of my problem is that when I am executing a task, I tend to dwell on specific problems I am facing with the task rather than focusing on completion of the task. I understand to keep thinking about it does not solve the problem. But I habitually do that and easily become exhausted. I hope I am not the only one feeling in this way. Did you feel the same feeling? If so, how did you get rid of this terrible habit? 
How to stop dwelling on problems rather than tasks?
productivity
One word; done. Focus on it, strive towards it, understand that it is what matters. Preparing for the ifs will generally equate to unneeded perceived value that allows the programmer to feel better about a situation but it unfortunately in no way delivers additional value.Always remember that done equates to immediate value and focusing on anything less than moving towards done is a waste of time, effort, and energy.