Interesting to note that ExtremeProgramming
has emerged as a methodology for programming; it appears to be based in
trial and error programming! Without tests and refactoring, it is not
workable at all. So why not design first, write tests to that design,
then program, test, perform refactoring and iterate?
That's exactly what ExtremeProgramming is, friend. Just do it in tiny increments.
"The differences between XP and trial-and-error are basically
two-fold: first, you solve each error as it comes up, so that it
doesn't compound with later errors. And second, you meant to do it that
way in the first place, rather than being forced to come back and deal
with unforeseen complications.