For me, making it right and making it run are an iterative process - and this is true even though I tend to think out algorithms in code.
If I start without planning, I'm like a car without a steering wheel. But almost always the actual writing reveals things that just aren't right with the plan - missing data or misunderstood documentation, for example. So I take a step back and reassess what data/algorithms/architecture is needed.
I personally would recommend that you start your coding projects - whether they be script or module - with something that you can code a bit and run, code a bit and run. That way you get a reality check on your plan and your plan gets to continually take new facts and understandings into account.