I try not to start writing code until I am at the point where it's pretty much just typing. It doesn't always work out this way, and it isn't necessarily always the right move, but it forces me to have a really clear mental model of the problem in question before I start committing things to paper (so to speak), which typically saves a refactoring or two down the road.