Need to refactor?
Refactoring should be part of your daily work. You are constantly refactoring your code to make it more readable / maintainable / reliable / reusable, etc.
Your code is a living document. If it does not change over time, it becomes stagnant.
Invest in testing. Invest in refactoring. Invest in writing good code.
source to share
While the other answers are correct, the power of Refactoring is that it allows you to redesign your code with predictable results. The biggest maintenance challenge is that it is nearly impossible to predict all the requirements for complex applications.
Most of them can be solved by adding a new feature such as a new report or command. But others will require re-developing part of your application. This is where refactoring and unit testing comes into play. By using refactoring techniques, you can safely make the necessary design changes.
This is not a cure for the entire technique, but another tool that improves the quality of your code. (initial programming, object orientation, etc.).
source to share
For starters: Refactoring is a tax. If the code works, then you are wasting time fixing the code that already works, now I see that the kinds of businesses look suspicious. The message I love is "Legacy is another word for code that works."
There are now a lot of problems with a growing code base that must be addressed before you start spending more time maintaining the code that develops functions.
I personally like the No Broken Windows philosophy.
source to share
If it's not broken, don't fix it.
But if you need to start installing components into new unpredictable requirements, then it is often necessary to identify bits that you can extract and reuse. You need to make sure that your changes introduce unexpected errors - so you need good test coverage.
source to share