Quick revision
The short answer
I would make the debt visible in a register that states what each item costs us in delivery speed or reliability, tie most refactoring to feature work in the same area, and reserve a protected share of each team's capacity for the rest. Large refactorings are run as small projects with goals and milestones, wide mechanical changes are automated with tools such as OpenRewrite, and we track lead time and change failure rate so everyone can see whether the investment is paying off.
What to remember
In this answer, we treated 'no time for refactoring' as a sign that debt had no visible price. We made it visible with a register stated in delivery and reliability costs, paid small debt as part of feature work, protected a share of capacity for debt outside feature paths, ran large refactorings as projects with milestones, automated wide mechanical changes with OpenRewrite recipes, and measured lead time and change failure rate to show the effect.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would make the debt visible in a register that states what each item costs us in delivery speed or reliability, tie most refactoring to feature work in the same area, and reserve a protected share of each team's capacity for the rest. Large refactorings are run as small projects with goals and milestones, wide mechanical changes are automated with tools such as OpenRewrite, and we track lead time and change failure rate so everyone can see whether the investment is paying off.
Why this question is asked
When teams say they never have time for refactoring, the debt usually is not the root problem; the problem is that the debt is invisible to the people who set priorities. Product managers see features, not the extra week each feature costs because of a tangled module. At the fifteen-year level, interviewers want to hear how we turn a vague complaint into decisions that product and engineering can make together. In this answer, we will recap what technical debt really is, make it visible, look at three ways to pay it down depending on size, see how automation handles the wide changes, and finish with how to measure the effect.
1A Quick Recap of Technical Debt
Technical debt is the extra cost we pay later because of shortcuts or outdated design today. Like financial debt, it has a principal, the work needed to fix it, and interest, the extra effort every change pays while it remains. A module with no tests and tangled dependencies charges interest on every feature that touches it: slower development, more bugs and more fear.
Not all debt is bad. Taking a shortcut to meet a real deadline can be a sound business decision, as long as it is a decision and the debt is repaid. The trouble starts when nobody tracks it, so the interest keeps growing until 'every feature is slow' and no single item seems urgent enough to fix. 'We never have time' is the symptom of debt that has no owner and no visible price.
2Make the Debt Visible With a Register
The first step is a debt register: a short, shared list where each item states, in business terms, what it costs. 'The pricing module is messy' does not compete with a feature in planning. 'Every pricing change takes about 8 extra days and caused 3 of last quarter's 7 incidents' does.
| Item | Cost today | Fix effort | Plan |
|---|---|---|---|
| Pricing rules duplicated in 3 services | ~8 extra days per pricing change; 3 incidents | 4 weeks | project next quarter |
| No tests around invoice builder | every change needs 2 days of manual testing | 1 week | with next invoice feature |
| JUnit 4 in 40 modules | blocks newer test tooling | automated recipe | OpenRewrite, one week |
| Spring Boot two versions behind | security patches delayed | 2 weeks | reserved capacity |
Teams fill the register from their own pain: incidents, slow changes, onboarding complaints. We keep it short, review it monthly and remove items that are done or no longer matter. Its main job is to let product and engineering compare debt with features using the same currency, time and risk.
3Pay Small Debt as Part of Feature Work
Most debt is best repaid where code is already changing. When a feature touches the invoice builder, the estimate includes adding tests and cleaning up the parts the feature needs. Kent Beck's advice fits well here: first make the change easy, which may be hard, then make the easy change.
This has two advantages. Effort goes to code that is actually changing, rather than to old code nobody touches, which may be ugly but costs nothing. And it does not need a separate negotiation, because the refactoring is simply part of doing the feature properly. The leadership part is making it normal: engineers should not have to apologise for including cleanup in an estimate.
4Reserve and Protect Capacity for the Rest
Some debt does not sit in the path of any feature: an outdated framework version, a slow build, flaky tests. For this, we agree with product leadership on a fixed share of capacity, commonly somewhere between 15 and 25 percent, depending on how much debt exists. The important word is protected. If the share disappears whenever a deadline comes close, teams learn that it was never real.
The register decides what the reserved capacity is spent on, and the teams report what it delivered, such as 'build time down from 22 to 9 minutes'. That reporting is what keeps the agreement alive in the next planning round.
5Run Large Refactorings as Projects
Some debt is too big for either approach, such as splitting a shared database or replacing a homegrown framework. Such work needs to be treated like any other project: a goal stated as an outcome, milestones that each deliver value on their own, an owner, and exit criteria. Patterns like the strangler fig, where new code gradually replaces the old behind a stable interface, let us ship in steps instead of in one risky switchover.
I would also insist on a 'stop' point for each milestone. A large refactoring that delivers nothing for six months loses support; one that improves something measurable every few weeks keeps it.
- Is the code in the path of planned features?YesFix it as part of that featureNoCheck its size
- Can it be done in a few days?YesUse reserved capacityNoPlan it as a project
- Is it a wide mechanical change?YesAutomate it with a recipeNoMilestones, owner, exit criteria
- Report the resultmeasured against the register's cost
4 steps in order. Play them, or step through them one at a time.
6Automate Wide Mechanical Changes
Many debt items are not hard, just wide: migrating 40 modules from JUnit 4 to JUnit 5, moving from javax to jakarta packages, upgrading Spring Boot. Doing these by hand across many teams takes months. Automated refactoring tools such as OpenRewrite apply recipes, which are tested transformations of the code's syntax tree, so the same change lands consistently everywhere.
A small platform team can run the recipe across all repositories and open pull requests, so each product team only reviews and merges. That turns a quarter of scattered effort into a week of central work.
7Measure the Effect
Finally, we show whether it worked. The DORA metrics are a good fit: lead time for changes, from commit to production, and change failure rate, the share of deployments that cause a failure. If refactoring the pricing module is worthwhile, lead time for pricing changes should drop and incidents there should fall, for example from 8 days to 3 and from 3 incidents a quarter to 1.
These numbers do two jobs. They tell us whether we are paying the right debt, and they give product leaders evidence that protecting capacity was a good trade. That evidence is what turns 'engineers want time to tidy up' into an investment the whole organisation supports.
8Follow-up questions
How do you convince a product manager who only wants features?
By talking in their terms. Show the register item for their area: how many extra days each feature costs and how many incidents it caused. Offer a small, time-boxed fix with a measurable outcome, then report the result. One visible success, such as pricing changes shipping twice as fast, does more than any argument about code quality.
What percentage of capacity should go to debt?
There is no universal number. Many organisations start around 20 percent and adjust: more when incidents and lead time are bad, less when the register is short. What matters more than the exact share is that it is agreed openly, protected under deadline pressure and accounted for with results.
How do you stop new debt piling up while you pay the old?
Make the cheapest checks automatic: formatting, static analysis, architecture tests in the build, and a definition of done that includes tests. When a team does take a deliberate shortcut, it goes into the register with an owner and a date, so it becomes a tracked decision instead of hidden debt.
9Conclusion
In this answer, we treated 'no time for refactoring' as a sign that debt had no visible price. We made it visible with a register stated in delivery and reliability costs, paid small debt as part of feature work, protected a share of capacity for debt outside feature paths, ran large refactorings as projects with milestones, automated wide mechanical changes with OpenRewrite recipes, and measured lead time and change failure rate to show the effect.
Open with
My first step would be to make the debt visible, because when teams say they never have time, it usually means product leadership cannot see what the debt costs.
Then, if they want more
I would ask teams to build a short debt register where each item says what it costs in business terms, for example 'pricing changes take eight extra days and caused three incidents last quarter', plus a rough fix effort. Then I would split how we pay it.
Debt in code that features are already touching gets fixed as part of those features, and the estimate includes it; that is where refactoring pays back fastest.
For debt outside feature paths, like framework upgrades or a slow build, I would agree a protected share of capacity with product, say around 20 percent, and the register decides how it is spent.
Large items, like untangling a shared database, become projects with a goal, an owner, milestones that each deliver something, and exit criteria, often using the strangler fig approach. Wide mechanical changes, like JUnit 4 to 5 or a Spring Boot upgrade, I would automate with OpenRewrite recipes run centrally, so teams just review pull requests.
And I would measure lead time for changes and change failure rate, ideally per area, so we can show that pricing changes went from eight days to three. Those results are what keep the capacity protected in the next planning cycle.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- JUnit 4, JUnit 5
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Several teams say they never have time for refactoring, and technical debt slows every...": https://scrivio-interview-library.netlify.app/java/clean-code/3764ffb608/