while (!compile()) {
fixCompilationErrors();
fixUnitTests();
rewriteUnitTestsThatNoLongerMakeSense();
WriteNewUnitTests();
}
Your iterate loop just became maybe twice or 3 times as long. Less iterations = worse code.Delete em. You should be iterating your unit tests.
Over time you will find some really useful unit tests for common mistakes, and others that are basically useless. Try and approach things from the perspective of what you would like to know works and not just tossing everything and the kitchen sink at the problem. When you find a bug add a unit test just in case it comes back, if you change major parts of the system, port the most useful unit tests and delete the rest.
I think of unit tests as saving you from the (I thought I just fixed this) problem.
PS: The major advantage of this approach is you keep adding more tests to the older parts of the system, which are also the most costly to change because other parts of the system assume it works. And assumptions you and your code is making can be really hard bugs to find and fix.
If you change that into writeAnAutomatedTestForItAndRunYourTestSuite() you get the following benefits:
1) Every test you write accrues value onto your test suite and helps you avoid problems later;
2) You don't need to spend time to figure out what you might have broken with your change - your test suite tells you in seconds;
3) You can say with some measure of certainty that it's extremely unlikely that your change broke anything.