In my experience, typing early and rapidly iterating and modifying, i.e. thinking on the page, is FAR more effective than spending tons of time in your own head trying to solve the problem elegantly before you ever type anything.
The exception to this might be spending time thinking about the very high level structure you want, since the initial structure you start with can lock you into pattern of trying to solve the problem that might not be the most effective.
The exception to this might be spending time thinking about the very high level structure you want, since the initial structure you start with can lock you into pattern of trying to solve the problem that might not be the most effective.