How to make refactoring a priority for the team

refactoringteamwork

The codebase I work with daily has no automated tests, inconsistent naming and tons of comments like "Why is this here?", "Not sure if this is needed" or "This method isn't named right" and the code is littered with "Changelogs" despite the fact we use source control. Suffice it to say, our codebase could use refactoring.

We always have tasks to fix bugs or add new features, so no time is put aside to refactor code to be better and more modular, and it doesn't seem to be a high priority.

How can I demonstrate the value of refactoring such that it gets added to our task lists? Is it worth it to just refactor as I go, asking for forgiveness rather than permission?

Best Answer

"It's better to ask forgiveness than permission" is true.

Why worry about it? Just refactor the most horrible parts.

You already know what the most costly errors are, right?

If you don't, then step 1 is to positively and unambiguously define the most costly, complex, error-ridden, bug-infested problem code.

Identify the number of trouble tickets, hours of debugging, and other very specific, very measurable costs.

Then fix something on that list of high cost problems.

When you have to ask forgiveness, you can point to cost reductions.


In case you aren't aware, refactoring requires unit tests to prove that the before-and-after behaviors match. Ideally, this should be an automated, coded test, for example, a unit test.

This means pick one thing. Write a unit test. Fix that one thing. You've made two improvements. (1) wrote a test and (2) fixed the code.

Iterate.

Related Topic