Refactoring has a price, not refactoring has a cost
The most foolproof way to avoid regressions is to <i>leave the code alone</i>.<p>The best testing is battle testing - if it is working well after plenty of contact with the customer then <i>leave the code alone</i>.<p>Bitter experience has taught me this.<p>---<p>I'm going to expand on my comment a bit - we need to be clearer on what (production) code <i>actually is</i>. We believe it is the definition of the runtime behavior of a given system (and of course it is exactly that).<p>However, for any reasonably complex system, a complete understanding of the definition/behavior is beyond any single person. Thus code is in fact a <i>recording</i> of the social and technical process of producing the system, and as such embeds decisions and solutions that may not be evident to anyone just reading the code.<p>When viewed in this light, it is easy to see how dangerous refactoring can be.