Technical Debt Management and Refactoring Questions
Identifying, prioritizing, and paying down technical debt sustainably. Covers recognizing debt, making the case to invest in it, refactoring safely behind tests, and balancing debt reduction against feature velocity. Includes keeping a codebase maintainable over the long term.
Identify the common sources of technical debt in a software organization. For each source, give a practical indicator or metric you would monitor to detect it early, and a simple detection method you could run against an existing codebase.
Sample Answer
Direct answer
Technical debt in a real organization comes from six recurring sources: rushed delivery under deadline pressure, deferred upgrades, missing tests, duplicated solutions, knowledge loss from turnover, and shortcuts taken without a repayment plan. Each has its own early-warning signal, so detecting them requires more than one metric.
Structured elaboration
| Source | Early indicator | Detection method |
|---|---|---|
| Rushed delivery | Spike in hotfixes shortly after a release | Correlate deploy dates with incident timestamps |
| Deferred upgrades | Dependencies several major versions behind | Automated dependency-audit scan (e.g. npm outdated, pip list --outdated) run on a schedule |
| Missing tests | Coverage trending down on recently-changed files | Coverage-delta check per PR, not just a global number |
| Duplicated solutions | The same logic appears with small variations across files/services | Static duplication detection (e.g. jscpd, PMD CPD) |
| Knowledge loss | One person authors the majority of commits to a module, then leaves | Git blame / commit-author concentration analysis per module |
| Undisciplined shortcuts | "TODO" / "FIXME" / "HACK" comment density rising | Grep-based comment audit, tracked over time |
Worked example
A quarterly audit of a mid-size codebase finds: 40 unresolved TODO/FIXME comments concentrated in the billing module (undisciplined-shortcut signal), the billing module's primary contributor left the company two months prior with no documented handoff (knowledge-loss signal), and npm outdated shows the payment SDK is three major versions behind (deferred-upgrade signal). All three point at the same module, which is exactly the kind of correlated signal that should escalate a module from "routine backlog item" to "priority review," even though no single metric alone would have triggered that.
Trade-offs & pitfalls
A single detection method catches only its own blind spot: static duplication detection misses semantically duplicated logic written differently, and commit-author concentration can flag a module that's simply owned by a specialist by design, not one that's actually at knowledge risk. Combine at least two independent signals before escalating a module, rather than acting on any single metric in isolation.
Describe a decision checklist you would use before deliberately accepting new technical debt to meet a launch date, for example by skipping some integration tests. Include the criteria to evaluate, which stakeholders must sign off, what documentation you would require (including a repayment plan), and the maximum lifespan you would allow the accepted debt to have before it must be revisited.
Sample Answer
Direct answer
A decision checklist for deliberately accepting debt needs four things: explicit criteria for what makes debt acceptable right now, a named sign-off from both engineering and the business stakeholder requesting the deadline, required documentation including a repayment plan, and a hard maximum lifespan after which the debt must be revisited regardless of other priorities.
Structured elaboration
- Criteria to evaluate: is the affected area isolated (low blast radius if something goes wrong) or does it sit on a critical path? Is the shortcut reversible (can it be safely undone if it causes problems) or does it lock in a hard-to-change decision? What's the realistic worst case if this debt is never paid down?
- Required sign-off: both an engineering lead (confirming the technical risk assessment) and the business stakeholder driving the deadline (confirming they understand and accept the trade-off, not just that they want the date met), so the acceptance isn't a unilateral engineering decision nor a business decision made in ignorance of the risk.
- Required documentation: what specifically is being skipped, why, the acceptance criteria from step 1, and a repayment plan with an owner and target date, filed as a ticket at the moment of acceptance.
- Maximum allowed lifespan: a hard date (not "soon") after which the debt is automatically escalated for review regardless of competing priorities; a common default is one quarter for most debt, shorter for anything touching a critical or customer-facing path.
Worked example
A team wants to skip load-testing a new endpoint to hit a launch date. Checklist walkthrough: isolated (yes, new endpoint, no existing traffic depends on it) and reversible (yes, can be feature-flagged off); worst case if debt persists is a capacity incident under unexpectedly high launch-day traffic. Sign-off: engineering lead confirms the technical risk is bounded given current traffic projections, and the product stakeholder explicitly acknowledges the capacity risk in writing. Documentation: ticket filed noting the skipped load test, owner assigned, repayment (running the load test) scheduled for the following sprint. Maximum lifespan: two weeks, shorter than the default quarter, because this item touches a customer-facing launch path.
Trade-offs & pitfalls
A checklist with no enforcement mechanism (no actual sign-off required, no automatic escalation at the lifespan deadline) becomes theater that gets rubber-stamped under the same deadline pressure it's meant to check; the maximum-lifespan escalation needs to be automated (a bot, a recurring calendar review) rather than relying on someone remembering to revisit it.
Explain technical debt using the principal-and-interest loan analogy, then distinguish intentional (strategic) debt from accidental (unintentional) debt. For each, give one concrete example of how it accumulates and name which stakeholder group typically introduces or first notices it.
Sample Answer
Direct answer
The loan analogy: technical debt has a principal (the corners cut to ship faster) and interest (the ongoing tax you pay in extra effort every time you touch that code until the principal is repaid). Martin Fowler's technical debt quadrant then splits debt along two axes: deliberate versus inadvertent, and reckless versus prudent. Reckless debt is a shortcut taken without understanding or caring about the consequences (skipping error handling entirely because nobody thought about what happens when a call fails, for example); prudent debt is a deliberate, informed trade-off made with eyes open, like the hardcoded-ranking-weight example below. The distinction that matters most day to day is intentional (strategic) debt versus accidental (unintentional) debt.
Structured elaboration
Intentional (strategic) debt is a conscious trade-off: the team knows a shortcut is being taken, why, and (ideally) has a repayment plan. Accidental (unintentional) debt is debt nobody chose, it emerged from evolving requirements, from not knowing a better approach at the time, or from the codebase outgrowing its original design.
| Intentional / strategic | Accidental / unintentional | |
|---|---|---|
| Example | Hardcoding a config value to hit a launch date, with a ticket filed to fix it | A module designed for 10 users now serving 10,000, and nobody planned for the scale shift |
| Who typically introduces it | Engineering + product, jointly, under deadline pressure | Any engineer, often without realizing it, as requirements evolve |
| Who typically first notices it | The same team, since they wrote the ticket | A different engineer months later, debugging something unrelated |
| Interest rate | Usually known upfront (the team estimated the cost of the shortcut) | Usually discovered too late (the interest was compounding silently) |
Worked example
A team ships a recommendation feature using a single hardcoded ranking weight instead of the planned configurable weighting system, to hit a launch date. That's intentional debt: product and engineering both signed off, and a ticket exists to build the real system next quarter. Separately, the same codebase's user-profile module was designed assuming one profile per user; eighteen months later, a business-account feature needs multiple profiles per organization, and half the codebase implicitly assumes the one-profile invariant. Nobody "chose" that debt; it's accidental, and it's usually more expensive to unwind because it's woven through more of the system before anyone notices.
Trade-offs & pitfalls
The common mistake is treating all debt as accidental (a moral failure to avoid) or all debt as intentional (a lever always available). In practice a large majority of real debt is accidental, which is exactly why passive vigilance (waiting to notice it) fails; you need active detection (metrics, architecture reviews) because accidental debt does not announce itself the way a filed ticket does.
A high-value customer reports slow page loads and occasional errors on a frequently used flow. Describe step by step how you would triage whether this is technical debt, a regression, or a genuinely new issue, what data you would collect to classify it correctly, and which stakeholders you would involve immediately.
Sample Answer
Direct answer
Triage by first checking WHEN the behavior changed relative to a known deploy or config change (points to a regression), comparing against historical incident patterns for that flow (points to known, pre-existing debt), and checking whether this is a genuinely new failure mode never seen before (points to a new issue); each answer routes to a different team and urgency level, so getting this classification right early prevents wasted effort and misdirected escalation.
Structured elaboration
- Immediate actions: reproduce the report if possible, check recent deploys and config changes to that flow (a regression is the most common and fastest-to-confirm cause), and check the error-rate/latency dashboards for that flow over the reporting period.
- Stakeholders to involve: the on-call engineer for that service immediately for triage; the account/success team to keep the customer updated with a realistic timeline once the category is known; engineering leadership only if it turns out to be a widespread, not isolated, issue.
- Data to collect for classification: deploy timestamps versus report timestamp (regression signal), whether other customers report the same symptom (widespread versus isolated), and whether this flow has a known, tracked debt item already (pre-existing debt signal) versus appearing nowhere in the tracker (genuinely new issue signal).
- Decision routing: a regression routes to an urgent rollback/hotfix path; a known, tracked debt item routes to the existing prioritization process (this incident is new EVIDENCE for that item's priority, not a new item); a genuinely new issue routes to standard bug triage.
Worked example
The report comes in Tuesday; checking deploy history shows the last deploy to that flow was two weeks prior, ruling out a regression from a recent change. Checking the debt register shows this exact flow has a tracked, medium-priority item ("checkout retry logic has known edge cases under high latency") filed three months ago. Conclusion: this is technical debt, not a new bug or a regression, and the correct action is escalating the EXISTING item's priority using this fresh incident as new evidence, rather than filing a duplicate bug or triggering an emergency rollback for a two-week-old deploy that isn't the cause.
Trade-offs & pitfalls
Misclassifying a regression as "probably just tech debt" delays a fast, cheap rollback fix; misclassifying known debt as "a new bug" creates duplicate tracking and loses the historical context (why it was deprioritized before, what's already been tried) that the existing item carries. Getting the classification right in the first 15 minutes saves significant downstream confusion.
Define test debt as a category of technical debt, and describe two practical tactics to reduce it quickly, such as targeted automation of the highest-risk paths and enforcing a test-pyramid shape. Explain how you would decide which tests to automate first.
Sample Answer
Direct answer
Test debt is the accumulated gap between the tests a codebase needs and the tests it has: missing coverage, brittle or flaky tests, and tests that pass without meaningfully verifying behavior. Two fast, practical tactics to reduce it: automate the highest-risk paths first rather than chasing a blanket coverage number, and enforce a test-pyramid shape (many fast unit tests, fewer integration tests, very few slow end-to-end tests) so the suite stays fast enough that people don't start skipping it.
Structured elaboration
- Targeted automation of critical paths: rank untested code by a combination of change frequency and business criticality (a checkout flow beats an admin settings page), and automate tests there first; this delivers risk reduction per engineer-hour far faster than chasing overall coverage percentage.
- Enforce the test pyramid: audit the current suite's shape (count of unit vs integration vs end-to-end tests and their respective run times); if end-to-end tests dominate, they're slow and flaky by nature, which erodes trust in the whole suite and is itself a source of NEW test debt as people start skipping or ignoring red builds.
Deciding what to automate first: score candidate areas on (a) how often the code changes (higher change frequency = higher risk of a regression slipping through) and (b) business criticality (revenue-path or compliance-relevant code outranks internal tooling), and start with the intersection of both being high.
Worked example
A codebase's untested areas: an admin-only reporting page (rarely changes, low criticality) and the checkout discount-code logic (changes almost every sprint, directly revenue-relevant). Despite the admin page having zero coverage and the checkout logic having partial coverage, the checkout logic is the higher-priority automation target, since its change frequency and criticality both point to it as the place most likely to regress silently and cause real damage.
Trade-offs & pitfalls
Chasing a blanket coverage percentage target ("get to 80% everywhere") often produces the OPPOSITE of risk reduction: teams write low-value tests against low-risk code to move the number, while the highest-risk, highest-change-frequency code stays under-tested because it's harder to test well. Targeted, risk-based automation is slower to show a clean percentage but faster to reduce real incident risk.
Unlock Full Question Bank
Get access to all 15 Technical Debt Management and Refactoring interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.