Daniel Roberts: I think you'll find that you're not unique. Most programmers I know (myself included) work in a similar fashion. Take Joel Spolsky for example - Joel tells us, "sometimes I just can't get anything done." [1]

The answer? Well according to Joel you just have to "launch the editor". Do you know what? Joel's right! I've verified this myself on many occasions. The routine goes something like this: I can't find the motivation to write code, I procrastinate, I browse the web... I fire up the editor and pretty soon I'm coding again - I might not be 100% productive but I do achieve something.

When I can't face tackling a new project/module, I pick an "issue" from the bug-tracker and work on a fix. Remember: You just have to keep walking forward!

Employers have a role to play too. Both Joel Spolsky and Paul Graham [2] (amongst others) have written extensively on this. The environment must be right, the right tools must be available, etc, etc.

Personally I don't believe any programmer can be 100% productive, 100% of the time (not even Graham's "Great Hackers"). Coding is like writing, or composing, or painting. You will have periods of greatness, but you'll also create "filler" every now and again and, sometimes, you'll create nothing at all.

[1] http://www.joelonsoftware.com/articles/fog0000000339.html

[2] http://www.paulgraham.com/gh.html