I don't try to avoid procrastinating.
Ok, that sounds wrong. Let me try again: I find that when I'm procrastinating about writing a particular piece of code, it's because there's something nagging at my subconscious telling me "this isn't the right way to solve this particular problems -- go away and think some more".
Once I know what the next step is and know that it's the right next step, I find that I don't procrastinate any more.