--Frank Herbert
Of course, the problem wasn't really abandoned -- I was thinking about how to solve it the whole time. But I wasn't writing any code.
Forcing yourself to write isn't necessarily best.
I don't smoke (never have) but I am trying to emulate that; the most effective way to solve a problem is to step out and do nothing for about 5 minutes. Take a walk. Look at the trees. Anything. Then when I come back I have either solved the problem or decided to leave it with a hacked together patch and work on something else; Ill probably still resolve the hack sometime later.
The opposite is to seek out some distraction, click around on facebook or HN or something - you solve nothing but spend lots of time....
Writing is apparently different in this regard.
Programming isn't just about generating more lines of code. It's about understanding the problem you're working on. Sometimes writing code is a good way to understand the problem.
Elizabeth Gilbert gave a great talk at TED on these topics: http://www.ted.com/talks/elizabeth_gilbert_on_genius.html (warning: auto-play video)
Don't be put off that she's the "Eat Pray Love" author if that's not your style (it's definitely not mine). She speaks very well to the creation process - and even touches on topics like depression and suicide among creators. It's well worth the watch.
Another great talk (that isn't quite as directly relevant) is JK Rowling's Harvard Commencement speech: http://www.youtube.com/watch?v=wHGqp8lz36c (also auto-play)
My favorite part of that one is her speaking against not creating and thereby failing by default.
Not all of the advice applies, of course, but there's a lot of good advice on making a good workspace and keeping yourself motivated. I've certainly noticed after working alone that there's a lot of implicit encouragement merely from working near other people, and this makes working at home harder than the same work might otherwise be. That's part of the reason why many prefer to work from cafes or worker/hacker-spaces, I think. Motivation is contagious.
(The positive flip side is that working from home removes a certain set of distractions that might otherwise be bothersome, and gives you more fine-grained control over the distractions you have in general).
Lots of authors use funny setups to transition from home-mode to work-mode. Some people build extra doors in their house so they can "leave" their house and "enter" an office that is sealed off from their house, but is otherwise the same building. One author (Roald Dahl?) worked from a bunker.
That being said, its probably a bad idea to get hung up on the idea of perfect working-from-home conditions. Per E. B. White:
"A writer who waits for ideal conditions under which to work will die without putting a word on paper."
Some similar important words from Tchaikovsky, which I found especially relevant to working from home:
Do not believe those who try to persuade you that composition is only a cold exercise of the intellect. The only music capable of moving and touching us is that which flows from the depths of a composer’s soul when he is stirred by inspiration. There is no doubt that even the greatest musical geniuses have sometimes worked without inspiration. This guest does not always respond to the first invitation. We must always work, and a self-respecting artist must not fold his hands on the pretext that he is not in the mood. If we wait for the mood, without endeavouring to meet it half-way, we easily become indolent and apathetic. We must be patient, and believe that inspiration will come to those who can master their disinclination.
I think motivation is under-stated in its importance when it comes to working from home. Even if our work demands little distraction, we're social creatures, and we've probably all had days where its hard to even open up the editor.
It's important to stay positive and stay at it. As Joel said, "We just have to come in every morning and somehow, launch the editor."[1]
[1] http://www.joelonsoftware.com/articles/fog0000000339.html