Stephan van Hulst wrote:Management will be much more likely to OK small refactors that will take a few hours to a day or two.
I agree with the other points about avoiding large refactorings but this thing about management being "OK with it" points to something that's wrong in the development culture. Developers should not have to ask permission from their managers to do the right thing. Developers should be honest in their estimates and transparent about what they are doing and they should be willing to make compromises to a certain extent. I think it's our responsibility as developers to educate managers about technical debt and its impact on the long-term viability of software. Help them understand that neglecting to make incremental refactoring will cost more in the long run. Tell them you NEED to spend some time paying down technical debt, don't ask permission to do it.
Here's a synopsis of how it usually goes otherwise:
1. Developer sees a need to refactor
2. Developer asks for permission
3. Manager says "No, we don't have time."
4. Developer gives estimates based on "ideal" situation
5. Developer is hampered by poor design / bad code that hasn't been refactored
6. Developer takes more time than he/she estimated in #4
7. Manager is not happy, puts more pressure on Developer
8. Developer makes more poor design/code decisions and choices
9. Developer finishes late and with low confidence in his/her work
10. The vicious cycle continues...
We developers need to take responsibility and reverse this vicious cycle. Make refactoring an integral part of the work that you do. Don't ask permission to do it.