Originally posted by Christophe Verre:
I'm not convinced that Agile would prevent that. Isn't there more fundamental problems behind that ? Or do you simply mean that with a good unit testing package, those unexpected side effects will be detected ?
Writing unit tests will in fact also reduce those side effects directly. Let me explain:
To effectively write unit tests, you need to have units that are testable. (Doh!) Testable units are units that are well decoupled from other units, and that are therefore easy to get into a test harness in isolation. So refactoring code so that it is testable leads to a better decoupled design.
Unexpected side effects mostly come from inappropriate coupling. By forcing you to better decouple your design, writing tests directly reduces the amount of unexpected side effects.
Frankly, for us it probably weren't unit tests that had the biggest effect, but rigorous refactoring. And yes, we refactored a lot without having tests in place. It's a risky undertaking, and I wouldn't really recommend it, but for is it actually worked out in the way that we at least removed many more bugs than we newly introduced.