Technical Debt and Refactoring Interview Questions

261 multiple-choice tech interview questions on Technical Debt and Refactoring: What technical debt is and how it accrues, the debt quadrant, code smells, refactoring techniques, working with legacy code and making the business case for paying debt down. Written for technical phone screens and interview prep, organized by subtopic, with a short explanation for every answer. Learn the 41 key terms with the flashcards first, then test yourself.

Take the practice test · Flashcards · All study tools

What it covers

  1. 8.1 Understanding technical debt
  2. 8.2 Code smells
  3. 8.3 Coupling, cohesion and simple design
  4. 8.4 Core refactoring techniques
  5. 8.5 Working with legacy code
  6. 8.6 Measuring code quality and debt
  7. 8.7 Dependency, platform and infrastructure debt
  8. 8.8 Prioritizing and paying down debt
  9. 8.9 Refactoring safely at scale

Key terms

8.1 Understanding technical debt

Technical debt
Future cost of rework from expedient choices now
Debt quadrant
Fowler's deliberate/inadvertent × reckless/prudent model

8.2 Code smells

Code smell
Surface symptom of a deeper design problem
God class
Class with too many responsibilities
Shotgun surgery
One change requires edits in many places

8.4 Core refactoring techniques

Refactoring
Improving structure without changing behavior
Boy Scout Rule
Leave code cleaner than you found it
Seam
Place to alter behavior without editing code there

8.8 Prioritizing and paying down debt

Hot spot
Frequently changed, complex code
YAGNI
Don't build what you don't need yet

8.9 Refactoring safely at scale

Principal
The cost to fix a debt shortcut
Interest
Extra effort a shortcut adds to every change
Architectural debt
Design choices that limit change
Test debt
Missing or weak automated tests
Essential complexity
Complexity inherent in the problem
Long parameter list
A function with too many inputs
Divergent change
One class changed for many reasons
Message chains
Long a.b().c() navigation
Middle man
A class that only delegates
Refused bequest
A subclass ignoring what it inherits
Magic number
An unexplained literal
Connascence
How changes ripple between parts
Preparatory refactoring
Reshaping code to ease the next change
Two hats
Refactor or add features, not both at once
Golden master
Comparing output to a saved snapshot
Sprout Method
New code in a new tested method
Wrap Method
New behavior around an old method
Code churn
How often code changes
Quality gate
Conditions code must meet to pass
Goodhart's law
A measure that becomes a target stops working
Architecture fitness function
An automated check of a design rule
End of life
When a product stops getting fixes
Lockfile
A file pinning exact dependency versions
Snowflake server
A hand-tuned server nobody can rebuild
Upgrade cliff
A big jump after skipping versions
Tech debt register
A tracked list of known debt
Debt sprint
A block of time for cleanup
Parallel change
Expand, migrate, then contract
Codemod
A script that rewrites code at scale
Ratchet
A rule that only lets a metric improve
Kill date
A planned removal deadline for old code

Sample practice questions

  1. What is technical debt?

    1. Money the company owes vendors for its software licenses and support
    2. The total number of open bug reports in the team's issue tracker
    3. Unpaid invoices that are still owed to outside contractors
    4. Future rework cost from choosing a quick solution over a better one now

    Answer: D. Future rework cost from choosing a quick solution over a better one now Ward Cunningham coined the metaphor; like financial debt, it accrues "interest" as extra effort on every change.

  2. What is a code smell?

    1. A syntax error that stops the code from compiling at all
    2. A surface sign that often points to a deeper design problem
    3. An automated test that fails every time it runs in CI
    4. A security vulnerability, by definition, that must be fixed

    Answer: B. A surface sign that often points to a deeper design problem Kent Beck and Martin Fowler catalogued smells in "Refactoring."

  3. What does the YAGNI principle warn against?

    1. Writing too few automated tests for new features
    2. Keeping the source code in version control at all
    3. Building features or abstractions before they're needed
    4. Removing dead code that nothing calls anymore

    Answer: C. Building features or abstractions before they're needed "You aren't gonna need it" from Extreme Programming; speculative generality is a related smell.

  4. What is refactoring?

    1. Adding new features to the application at the request of its users
    2. Rewriting the whole application in a newer programming language
    3. Restructuring code to be clearer and easier to change, without changing behavior
    4. Fixing the bugs that users have reported through the support desk

    Answer: C. Restructuring code to be clearer and easier to change, without changing behavior Martin Fowler's definition stresses behavior preservation.

  5. What is the strangler fig approach to replacing a legacy system?

    1. Rewriting the entire system at once and switching over in one weekend
    2. Leaving the legacy system completely untouched, forever, as it is
    3. Deleting the legacy system's database first, then rebuilding the rest
    4. Building new parts around the old system and routing over piece by piece

    Answer: D. Building new parts around the old system and routing over piece by piece Big-bang rewrites are notoriously risky.

  6. What does hot spot analysis (combining change frequency and complexity) help with?

    1. Finding which servers in the data center are running the hottest
    2. Finding complex files that change often, where paying debt pays most
    3. Choosing which developers on the team should be promoted next
    4. Detecting Wi-Fi hot spots near the office for remote workers

    Answer: B. Finding complex files that change often, where paying debt pays most Adam Tornhill's "Your Code as a Crime Scene" popularized this approach.

  7. Why can outdated dependencies be dangerous technical debt?

    1. They make the application run noticeably faster than it should
    2. They miss security patches, and upgrades get harder over time
    3. Updates to dependencies never include any breaking changes
    4. Older versions of libraries don't contain any bugs at all

    Answer: B. They miss security patches, and upgrades get harder over time Tools such as Dependabot and Renovate keep dependencies current in small steps.

  8. How can a team make technical debt visible?

    1. Track debt in the backlog with impact, plus metrics like rework time
    2. Keep it in developers' heads so the backlog stays short and clean
    3. Hide it from the Product Owner so it doesn't distract from features
    4. Delete any tickets about technical debt that are older than a month

    Answer: A. Track debt in the backlog with impact, plus metrics like rework time Visible debt can be prioritized like other work.

  9. A shared function's signature must change, with 200 callers. What's a safe path?

    1. Copy the function 200 times
    2. Add the new one, migrate, delete old
    3. Change all 200 in one risky PR
    4. Leave both versions forever

    Answer: B. Add the new one, migrate, delete old Expand, migrate, contract.

  10. What is the "interest" on technical debt?

    1. A monthly fee that cloud providers charge for old resources
    2. A fixed percentage of each developer's salary set aside
    3. The extra effort and risk the shortcut adds to future changes
    4. The cost of buying replacement hardware every few years

    Answer: C. The extra effort and risk the shortcut adds to future changes Debt in rarely changed code carries little interest; debt in hot spots is expensive.

Practice all 261 questions

More Development Practices