That's a false choice. Certainly you should not shut down your brain,
and if you don't understand your code starting over is usually good.
But it is entirely possible to use a debugger with your brain on.
Then test as you go. Write a simple test, write the code to pass it,
check in. Repeat until done.
Yes. (But make sure the tests are correct. Sometimes, like bad specs,
it's easy to get both wrong in compatible ways; that doesn't help.)
Then if you add come code that breaks, just revert the change and do it
again.
But no. _Look_ at the change(s) first to try to figure out the
problem. 99% of the time you will find it, with much less effort than
investigating or analyzing the whole program. And that's a win.
But don't assume that the problem _must_ be in the last change, or
even last few. Sometimes a code change -- or a test change -- will
expose a latent bug that was already there, in code that didn't
change, sometimes code that has been there for years. We tell
ourselves, and each other, "oh, that code has been extensively tested
and widely used, it can't be wrong" but for (sub)programs of any
significant complexity and/or context the number of possible execution
histories is usually so huge that no testing could ever be exhaustive.
- formerly david.thompson1 || achar(64) || worldnet.att.net