This is excellent advice, thanks.
With regards to writing all the tests first, i've been reading up on Test Driven Development and this seems like the core point. Does this work out in practice? I know that when i start a project i tend to jump in and start coding! Half out of excitement and half out of necessity.
Also, how do i apply this method to existing scripts where i don't have test written?
Are there any good documents or links you know of that show the best approach to take?