An example of preparatory refactoring
martinfowler.com
martinfowler.com
What I take away is that if you refactor before adding new functionality, the refactoring is a lot easier because you can test that the functionality doesn't change at all. If you refactor after you add new functionality, you have to test all at once that there are no regressions and that the new functionality works, so the refactoring becomes as stressful as adding new functionality.