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.
A key customer requests a customization that would add a brittle integration and increase your maintenance burden. Describe how you would evaluate this request, weighing short-term revenue against long-term maintenance cost, propose alternatives that reduce the ongoing burden, and outline how you would communicate your decision to the customer and to sales.
Sample Answer
Direct answer
Evaluate a brittle-integration customization request by weighing the immediate revenue against the ongoing maintenance cost it locks in, and default to steering toward a lower-maintenance alternative (a paid customization, a managed plugin, or a partner integration) rather than accepting the ad hoc integration outright, since the revenue is one-time or recurring-but-bounded while the maintenance burden compounds indefinitely.
Structured elaboration
- Quantify both sides: the deal's revenue value (one-time or annual contract value) against a realistic estimate of ongoing maintenance cost (engineer-hours per quarter to keep the brittle integration working, especially across future platform changes it wasn't designed to survive).
- Look for a structurally cheaper alternative first: a paid customization (the customer pays extra for the one-off work, changing the economics), a managed plugin architecture (if this is likely to recur with other customers, building a supported extension point once is cheaper than N bespoke integrations), or a partner/vendor integration (offloading the maintenance to a third party who specializes in it).
- Decide with a threshold: if the deal's value clearly exceeds a multi-year projection of maintenance cost AND no cheaper alternative exists, accept it, but with the same deliberate-debt-acceptance discipline (documented, sign-off, a review date) used for any other consciously accepted debt.
- Communicate the decision: to the customer, framed around value ("we can build this in a way that's more reliable long-term" rather than "we don't want to"); to sales, framed around the real trade-off (revenue now versus a compounding support cost that will eventually eat into margin on this and future similar deals).
Worked example
A customer's request would add a brittle webhook integration worth $40,000/year in contract value, but a rough estimate puts ongoing maintenance at roughly 10 engineer-hours/quarter (40 hours/year) at a fully-loaded cost of roughly $85/hour, or $3,400/year, which looks favorable in isolation. The complicating factor: this is the third similar request in six months, suggesting a pattern rather than a one-off; building a lightweight, reusable integration extension point instead (a larger one-time investment, but reusable for this and future similar requests) is proposed to sales as the better long-term path, and the customer's specific request becomes the first user of that extension point rather than its own bespoke, brittle addition.
Trade-offs & pitfalls
Evaluating each request in isolation, as this one initially looks favorable, misses the PATTERN across requests; the real analysis this question rewards is recognizing when a seemingly-good individual trade-off is actually evidence of a recurring need that deserves a structural, reusable solution instead of a growing pile of one-off brittle integrations.
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.
How would you redesign team incentives and OKRs so engineering, product, and customer-success teams are jointly accountable for reducing technical debt and improving product quality over the next year? Provide example first-quarter OKRs that reflect this alignment and describe how you would track progress.
Sample Answer
Direct answer
Redesign incentives so engineering, product, and customer success share OKRs tied to shared outcomes (not separate function-specific goals that happen to touch quality), with each function's individual OKRs explicitly linked to the shared one, so debt reduction stops being "engineering's problem" that others merely tolerate.
Structured elaboration
- Shared outcome OKR: a single, org-level objective all three functions contribute to, for example "reduce customer-impacting quality issues while maintaining feature velocity," with key results spanning all three functions' natural metrics (engineering: incident rate and cycle time; product: feature-adoption-adjusted for quality issues; customer success: quality-related ticket volume).
- Function-level OKRs link back explicitly: each function's own quarterly OKRs include at least one key result that ties directly to the shared objective, so it's visible in each function's own planning, not just in a separate cross-functional document nobody revisits.
- Joint accountability mechanism: a shared quarterly review where all three functions report against the shared objective together, not three separate updates in three separate meetings, so trade-offs and mutual dependencies are visible in the room.
Worked example, first-quarter OKRs:
- Shared objective: "Reduce customer-impacting quality issues by 30% while holding feature velocity flat."
- Engineering KR: reduce incident rate in the top 3 highest-incident services by 30%, and hold cycle time within 10% of current baseline.
- Product KR: for every major feature shipped this quarter, a documented quality/debt review occurs before commitment (process KR, since a direct quality-outcome KR for product alone would be too indirect).
- Customer success KR: quality-related ticket volume down 25%, tracked and reported alongside the engineering incident-rate KR in the same joint review, not separately.
Tracking progress: a shared quarterly dashboard showing all three KRs together, reviewed jointly rather than function-by-function, so a shortfall in one area (say, product's process KR slipping) is visible as a shared problem in the same conversation as engineering's incident-rate progress, not siloed into a separate report nobody cross-references.
Trade-offs & pitfalls
The common failure in cross-functional OKR design is each function getting a token, disconnected KR that technically checks the "joint accountability" box without creating any real shared incentive; the design above avoids that by requiring each function's KR to be reported and reviewed IN THE SAME meeting as the others, which is what actually creates the shared visibility and mutual pressure that makes joint accountability real rather than nominal.
You need to create an executive-facing dashboard that quantifies technical debt impact for leadership who do not read engineering metrics day to day. Propose six to eight metrics, explain why each is valuable to a non-engineering audience, how you would measure it, and what threshold would signal it needs urgent attention.
Sample Answer
Direct answer
An executive dashboard needs 6-8 metrics that translate directly into business risk without requiring engineering context to interpret: cycle time, build failure rate, test coverage, mean time to recovery, bug escape rate, and deploy frequency, each with a plain-language "why this matters" and a threshold that means "needs attention now."
Structured elaboration
| Metric | Why it matters to leadership | How you'd measure it | Threshold for concern |
|---|---|---|---|
| Cycle time | How fast a fix or feature reaches customers | Timestamp from first commit (or ticket start) to production deploy, pulled from git and the CI/CD system | Rising trend over 2+ sprints |
| Build failure rate | Direct measure of how often work gets blocked | Percentage of CI pipeline runs that fail, pulled directly from the CI dashboard | Above ~15% sustained |
| Test coverage (trend, not absolute) | Proxy for how safely changes can be made | Percentage of code lines or branches exercised by automated tests, from the coverage tool wired into CI | Falling for 2+ consecutive months |
| Mean time to recovery | How long customers are impacted during an incident | Average time from incident-declared to incident-resolved, from the on-call/incident-tracking system | Above the team's SLA (service-level agreement, the response and recovery time promised to customers) target |
| Bug escape rate | Quality reaching customers, not caught internally | Post-release bugs divided by total bugs found (pre- and post-release), from the issue tracker | Rising trend, especially post-release |
| Deploy frequency | Velocity of value delivery | Count of production deployments per week, from the CI/CD deployment log | Falling trend |
Add two more only if they map to a specific business concern this quarter, for example incident count (if reliability is the current executive focus) or dependency-freshness (if security/compliance is the current focus); resist the urge to include every available metric, since a crowded dashboard defeats the purpose of an executive-facing view.
Worked example
A quarterly executive review shows deploy frequency down 30% and bug escape rate up 20% over the same period, both crossing their concern thresholds simultaneously. Presented together, these two numbers tell a coherent story ("we're shipping less, and what we do ship has more defects") that a single metric alone wouldn't convey as clearly, and it directly motivates the capacity-allocation ask without requiring the executive to understand cyclomatic complexity or test architecture.
Trade-offs & pitfalls
The pitfall specific to this audience is presenting metrics without translating WHY each matters in business terms; an executive dashboard that just relabels an engineering dashboard still requires the same context to interpret. A second pitfall: setting thresholds too sensitively, so the dashboard cries wolf every sprint and executives stop trusting it exactly when it matters most.
A core payments module shows high error rates and slow feature delivery due to legacy code. Walk through how you would evaluate a refactor versus a rewrite for this module, including the criteria you would use, a proof-of-concept step to reduce uncertainty before committing, and a rollout and rollback plan for whichever path you choose.
Sample Answer
Direct answer
For a core payments module with high error rates and slow delivery, evaluate refactor versus rewrite on measurable risk, customer impact, developer productivity, and time to deliver, run a small proof-of-concept to reduce uncertainty before committing to either path, and require an explicit rollout/rollback plan regardless of which path wins, since payments carries unusually low tolerance for a bad cutover.
Structured elaboration
- Assess current-state risk: how well is existing behavior understood? For a payments module, a rewrite needs high confidence in reproducing exact behavior (rounding rules, currency handling, retry semantics) or it introduces MORE risk than the debt it removes.
- Proof-of-concept before committing: build a small, isolated piece of the rewrite (e.g., just the fee-calculation logic) and run it in shadow mode against production traffic, comparing outputs to the existing system without affecting real transactions. This surfaces unknown edge cases cheaply before a full rewrite commitment.
- Decision criteria: if the PoC's shadow-mode comparison shows the new logic matches existing behavior within an acceptable tolerance (and any mismatches are explainable, not mysterious), that's evidence favoring rewrite; if it surfaces a long tail of unexplained discrepancies, that's evidence the existing system's behavior is more complex than believed, favoring incremental refactor instead, since a full rewrite would be reproducing unknowns rather than knowns.
- Rollout and rollback plan: dual-run the new path behind a flag, compare outputs in production for a defined window (e.g., two full billing cycles, to catch any monthly-cadence edge cases), then cut over gradually with an immediate rollback trigger on any discrepancy in a real (not shadow) transaction.
Worked example
The PoC shadow-tests the fee-calculation logic against 30 days of real production traffic without affecting live transactions. Results: 99.7% exact match, with the 0.3% mismatch traced entirely to a currency-rounding edge case in one specific region, which is fixable and explainable, not a sign of deeper hidden complexity. This result favors proceeding with an incremental rewrite of the fee-calculation component specifically (not the whole payments module), since the PoC demonstrated the behavior IS well-understood enough to reproduce safely, while the rest of the module (which wasn't PoC'd) stays on an incremental-refactor track pending its own risk assessment.
Trade-offs & pitfalls
The temptation in a high-visibility case like "payments module has high error rates" is to commit to a full rewrite immediately as a visible, decisive action; the PoC step exists specifically to slow that impulse down long enough to discover whether the underlying behavior is actually well-enough understood to rewrite safely, which for payments logic (with its history of accumulated edge-case handling) is often not true for the whole module even when it's true for one well-scoped piece of it.
Unlock Full Question Bank
Get access to all 25 Technical Debt Management and Refactoring interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.