
Ask HN: How do you convince your managers to allow time for refactoring? - nodelessness
How do you convince the business that there is a good case for refactoring and convince them that there is value in doing so? It seems like every single place I go to, business priorities are always urgent and there is almost never any push being done to refactor code. Have you managed to get buy-in if so, how?
======
rapnie
Maybe by quantifying the cost with a concrete example.

Take a particular convoluted piece of code from your codebase, preferably
having a bug in it that exists in your issue tracker.

Show your manager this code, by scrolling through it (he/she does not have to
understand it). Now you say: "We have this bug in this code, which cost me 4
hrs to solve. I had to debug, consult team members, etc. Now had we refactored
this code before, the bug would already be eliminated and never reached the
customer. Here I have the refactored code, which took me 2 hrs to create.
Looks much cleaner, right? Even if the bug had remained in this code, I would
have found and fixed it within an hour, and so would the next guy without
having to bother other team members. When I refactored I even found yet
another bug in the original code that hadn't been detected yet."

Refactoring turned out to be cheaper in any way, and avoids the hit to
customer satisfaction if it goes into production.

