Test, test, and test again
There is no way around this, in order to refactor code, you need a solid set of tests. Refactoring code may well reduce the chances of introducing bugs, but changing the design of code introduces a significant amount of chances to introduce new bugs.
Unintended side-effects will occur during refactoring, where classes are tightly coupled, you may well find making a minor change to one function leading to a negative side-effect in a completely separate class.
Good refactoring effects require good tests. There is simply no way around this.
In addition to this, from a more political standpoint, some companies which have encountered the bad effects of repetitively bad refactoring efforts may become reluctant to refactor code; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access