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
- 8.1 Understanding technical debt
- 8.2 Code smells
- 8.3 Coupling, cohesion and simple design
- 8.4 Core refactoring techniques
- 8.5 Working with legacy code
- 8.6 Measuring code quality and debt
- 8.7 Dependency, platform and infrastructure debt
- 8.8 Prioritizing and paying down debt
- 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
What is technical debt?
- Money the company owes vendors for its software licenses and support
- The total number of open bug reports in the team's issue tracker
- Unpaid invoices that are still owed to outside contractors
- 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.
What is a code smell?
- A syntax error that stops the code from compiling at all
- A surface sign that often points to a deeper design problem
- An automated test that fails every time it runs in CI
- 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."
What does the YAGNI principle warn against?
- Writing too few automated tests for new features
- Keeping the source code in version control at all
- Building features or abstractions before they're needed
- 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.
What is refactoring?
- Adding new features to the application at the request of its users
- Rewriting the whole application in a newer programming language
- Restructuring code to be clearer and easier to change, without changing behavior
- 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.
What is the strangler fig approach to replacing a legacy system?
- Rewriting the entire system at once and switching over in one weekend
- Leaving the legacy system completely untouched, forever, as it is
- Deleting the legacy system's database first, then rebuilding the rest
- 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.
What does hot spot analysis (combining change frequency and complexity) help with?
- Finding which servers in the data center are running the hottest
- Finding complex files that change often, where paying debt pays most
- Choosing which developers on the team should be promoted next
- 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.
Why can outdated dependencies be dangerous technical debt?
- They make the application run noticeably faster than it should
- They miss security patches, and upgrades get harder over time
- Updates to dependencies never include any breaking changes
- 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.
How can a team make technical debt visible?
- Track debt in the backlog with impact, plus metrics like rework time
- Keep it in developers' heads so the backlog stays short and clean
- Hide it from the Product Owner so it doesn't distract from features
- 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.
A shared function's signature must change, with 200 callers. What's a safe path?
- Copy the function 200 times
- Add the new one, migrate, delete old
- Change all 200 in one risky PR
- Leave both versions forever
Answer: B. Add the new one, migrate, delete old Expand, migrate, contract.
What is the "interest" on technical debt?
- A monthly fee that cloud providers charge for old resources
- A fixed percentage of each developer's salary set aside
- The extra effort and risk the shortcut adds to future changes
- 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.