Chapter 34 Quiz: Managing Technical Debt

Test your understanding of technical debt management in AI-generated codebases. Each question has one best answer unless otherwise stated.


Question 1

What is the fundamental difference between technical debt created by human developers and debt created by AI coding assistants?

  • A) AI-generated debt is always worse than human-generated debt
  • B) Human developers typically know when they are taking shortcuts; AI does not have this awareness
  • C) AI-generated debt only affects code style, not functionality
  • D) Human-generated debt is easier to fix
Answer **B) Human developers typically know when they are taking shortcuts; AI does not have this awareness.** When human developers take shortcuts, they usually do so consciously and may leave TODO comments or file tickets. AI generates code without the concept of "shortcut" versus "proper solution," making the resulting debt invisible to the person who accepted it (Section 34.1).

Question 2

Which of the following is NOT one of the seven AI-specific debt patterns described in this chapter?

  • A) Style drift across sessions
  • B) Hallucinated patterns that work
  • C) Race condition introduction
  • D) Dependency bloat
Answer **C) Race condition introduction.** The seven AI-specific debt patterns are: style drift across sessions, copy-paste duplication, over-engineered solutions, hallucinated patterns that work, missing abstractions, shallow understanding debt, and dependency bloat. Race conditions are a bug category, not a debt pattern (Section 34.2).

Question 3

A codebase has email validation implemented in three different files, each with a slightly different regex pattern. Which AI-specific debt pattern does this represent?

  • A) Style drift
  • B) Copy-paste duplication
  • C) Over-engineering
  • D) Hallucinated patterns
Answer **B) Copy-paste duplication.** This is a classic example of copy-paste duplication, where AI generates self-contained implementations without awareness of existing code in the project. Each validation function works independently but duplicates logic that should exist in a single shared location (Section 34.2, Pattern 2).

Question 4

What does the Technical Debt Ratio (TDR) measure?

  • A) The number of debt items divided by lines of code
  • B) The cost of remediation divided by the cost of rewriting, expressed as a percentage
  • C) The ratio of complex functions to simple functions
  • D) The percentage of code that was generated by AI
Answer **B) The cost of remediation divided by the cost of rewriting, expressed as a percentage.** TDR = (Remediation Cost / Rewrite Cost) x 100%. A TDR below 5% is generally manageable, 5-10% warrants attention, and above 10% suggests significant intervention is needed (Section 34.4).

Question 5

You discover a dependency with a known security vulnerability in your project. According to the decision tree, what should you do?

  • A) Add it to the debt catalog and reassess quarterly
  • B) Fix it in the next sprint
  • C) Fix it immediately
  • D) Schedule a fix when you next modify that module
Answer **C) Fix it immediately.** The decision tree's first check is "Is it a security issue?" If yes, fix immediately. Security debt compounds faster than any other kind, and a vulnerability discovered by a bad actor is infinitely more expensive than one fixed proactively (Section 34.8).

Question 6

Which metric measures how difficult code is for a human to understand, accounting for nested control structures?

  • A) Cyclomatic complexity
  • B) Cognitive complexity
  • C) Maintainability index
  • D) Halstead volume
Answer **B) Cognitive complexity.** Cognitive complexity, developed by SonarSource, specifically measures how difficult code is for a human to understand, accounting for nested control structures and breaks in linear flow. It correlates better with perceived difficulty than cyclomatic complexity (Section 34.4).

Question 7

What is the "Boy Scout Rule" in the context of technical debt management?

  • A) Always write unit tests before code
  • B) Leave the code better than you found it
  • C) Scout for bugs before every release
  • D) Prepare for technical disasters before they happen
Answer **B) Leave the code better than you found it.** The Boy Scout Rule means that every time you touch a file for any reason, you make a small improvement — fix a naming inconsistency, remove an unused import, add a missing type hint. Over time, this incrementally improves the most frequently modified parts of the codebase (Section 34.5).

Question 8

An AI assistant generates a configuration loader using the Strategy pattern, Abstract Factory, and Builder pattern for a project that simply reads a JSON file. Which debt pattern is this?

  • A) Style drift
  • B) Shallow understanding
  • C) Over-engineered solutions
  • D) Hallucinated patterns
Answer **C) Over-engineered solutions.** Over-engineering creates debt by increasing cognitive load, adding unnecessary abstraction layers, and making simple changes more difficult. AI models, trained on enterprise code and design pattern examples, may produce solutions that are technically correct but wildly over-engineered for the actual requirements (Section 34.2, Pattern 3).

Question 9

In the effort-impact matrix, which quadrant should be addressed first?

  • A) High effort, high impact (Major Projects)
  • B) Low effort, low impact (Nice to Have)
  • C) Low effort, high impact (Quick Wins)
  • D) High effort, low impact (Not Worth It)
Answer **C) Low effort, high impact (Quick Wins).** Quick Wins provide the best return on investment because they deliver high impact with minimal effort. They should be addressed first, followed by Major Projects (planned carefully), Nice to Have (addressed opportunistically), and Not Worth It (accepted or deferred) (Section 34.5).

Question 10

What percentage of development time is typically recommended as a "debt budget"?

  • A) 1-5%
  • B) 10-20%
  • C) 30-40%
  • D) 50% or more
Answer **B) 10-20%.** Some teams allocate 10-20% of their development capacity to debt reduction. This ensures steady progress on debt without requiring explicit justification for each item and normalizes debt work as a routine part of development (Section 34.8).

Question 11

Which of the following is the MOST appropriate way to communicate technical debt to a product manager?

  • A) "Our cyclomatic complexity has risen to 14.3 across key modules"
  • B) "The AI wrote bad code and we need time to fix it"
  • C) "Feature delivery has slowed by 30% due to code inconsistencies that we can address in a focused two-week effort"
  • D) "We need to refactor the entire codebase; no new features for three months"
Answer **C) "Feature delivery has slowed by 30% due to code inconsistencies that we can address in a focused two-week effort."** Effective stakeholder communication translates technical concepts into business terms (velocity, risk, cost) with specific, actionable recommendations. Options A and D use jargon or are too extreme, and option B blames the tool rather than framing the issue constructively (Section 34.9).

Question 12

What is a "hallucinated pattern" in the context of AI-generated code?

  • A) Code that references non-existent APIs or libraries
  • B) A coding pattern invented by the AI that works but does not match any standard framework convention
  • C) Code that the AI imagined but never actually generated
  • D) A design pattern that the AI incorrectly names
Answer **B) A coding pattern invented by the AI that works but does not match any standard framework convention.** Hallucinated patterns work correctly but confuse experienced developers and resist integration with standard tooling. They create debt because developers cannot find documentation, and the patterns do not follow the idioms of the language or framework ecosystem (Section 34.2, Pattern 4).

Question 13

When using AI to remediate technical debt, what is the MOST important step after generating the remediated code?

  • A) Immediately committing it to the main branch
  • B) Running the full test suite and manually testing affected features
  • C) Asking the AI to confirm its output is correct
  • D) Measuring the cyclomatic complexity of the new code
Answer **B) Running the full test suite and manually testing affected features.** AI refactoring can introduce subtle bugs, especially when simplifying code that handles edge cases not visible in the AI's context. Testing is essential — both automated tests and manual verification of affected features (Section 34.6).

Question 14

What does the "Pattern Consistency Score" metric measure?

  • A) How many design patterns are used in the codebase
  • B) The percentage of modules that follow the dominant approach for each architectural pattern
  • C) How consistent the AI's output is across different prompts
  • D) The ratio of documented patterns to undocumented patterns
Answer **B) The percentage of modules that follow the dominant approach for each architectural pattern.** For each architectural pattern (database access, error handling, API response formatting), the Pattern Consistency Score calculates the percentage of modules that follow the dominant approach. A score below 70% indicates significant style drift (Section 34.4).

Question 15

Which of the following is NOT a recommended component of a project conventions document?

  • A) Naming conventions for variables, functions, and classes
  • B) Approved dependency list
  • C) Specific AI model and version to use
  • D) Error handling approach
Answer **C) Specific AI model and version to use.** A conventions document should cover naming conventions, architectural patterns, code organization, approved dependencies, error handling, and testing conventions. The specific AI model used is not a code convention and may change frequently (Section 34.7).

Question 16

A file has high code churn (frequently modified) AND high cyclomatic complexity. What does this indicate?

  • A) The file is well-tested
  • B) The file is a prime candidate for debt remediation
  • C) The file should be deleted
  • D) The file needs more comments
Answer **B) The file is a prime candidate for debt remediation.** Files with high churn and high complexity are both hard to work with and frequently worked on. This combination means that the debt in these files has the highest ongoing cost and therefore the highest return on investment for remediation (Section 34.4).

Question 17

What is the "strangler fig pattern" in the context of debt remediation?

  • A) Gradually replacing debt-laden code by wrapping it in a clean interface and migrating incrementally
  • B) Removing all technical debt at once in a single large refactoring
  • C) Letting old code die naturally by not maintaining it
  • D) Adding more abstraction layers on top of problematic code
Answer **A) Gradually replacing debt-laden code by wrapping it in a clean interface and migrating incrementally.** The strangler fig pattern wraps debt-laden code in a new, clean interface. New features use the clean interface while old code continues to work. Over time, old code is migrated to the new interface and the wrapper is removed (Section 34.6).

Question 18

When should technical debt be accepted rather than fixed? (Select the best answer)

  • A) When the team is too busy with features
  • B) When the debt is isolated to a single module with a clean interface and the fix cost exceeds the ongoing cost
  • C) Whenever the product manager says so
  • D) Technical debt should never be accepted
Answer **B) When the debt is isolated to a single module with a clean interface and the fix cost exceeds the ongoing cost.** Debt confined to a single module with a clean interface is less harmful than debt spread across the codebase. When the cost of fixing it exceeds the cost of living with it, accepting the debt is a rational business decision (Section 34.8).

Question 19

What are the three options presented for dealing with an unsustainable level of technical debt?

  • A) Ignore it, document it, or rewrite it
  • B) Aggressive remediation, selective rewrite, or full rewrite
  • C) Hire more developers, use better AI, or start over
  • D) Reduce features, increase testing, or freeze the codebase
Answer **B) Aggressive remediation, selective rewrite, or full rewrite.** Aggressive remediation dedicates 50-80% of capacity to debt reduction for a fixed period. Selective rewrite targets the most debt-laden modules. Full rewrite starts over entirely. All three approaches should apply the lessons from the chapter: establish conventions first, use templates, maintain AI context, set up review gates, and track metrics from day one (Section 34.10).

Question 20

Which of the following is an example of "shallow understanding debt"?

  • A) Using an outdated library version
  • B) Code that handles the happy path well but misses domain-specific edge cases and boundary conditions
  • C) Inconsistent variable naming across modules
  • D) An unnecessary dependency on a third-party library
Answer **B) Code that handles the happy path well but misses domain-specific edge cases and boundary conditions.** Shallow understanding debt reflects the AI's lack of deep domain knowledge. The code works for typical inputs but fails on edge cases, boundary conditions, and domain-specific invariants that an experienced domain expert would catch (Section 34.2, Pattern 6).

Question 21

What is the recommended frequency for reviewing the debt catalog?

  • A) Daily
  • B) Weekly
  • C) Monthly or quarterly, depending on project pace
  • D) Annually
Answer **C) Monthly or quarterly, depending on project pace.** The chapter recommends reviewing the debt catalog quarterly (or monthly for fast-moving projects). Items that have been deferred for more than two quarters should be reassessed, as their cost of delay may have increased (Section 34.5).

Question 22

What is the primary advantage of using template files for new modules in AI-assisted development?

  • A) Templates make the AI generate code faster
  • B) Templates ensure new modules follow established patterns, preventing style drift
  • C) Templates eliminate the need for code review
  • D) Templates reduce the amount of AI-generated code
Answer **B) Templates ensure new modules follow established patterns, preventing style drift.** Template files provide a starting point for new modules that already follows project conventions. When you tell the AI to "create a new ProductService following the patterns in this template," the result is much more consistent than generating from scratch (Section 34.7).

Question 23

In the priority scoring formula priority = (cost_of_delay + risk) * effort_score, why is the effort score inverted (low effort scores high)?

  • A) Because it is a mathematical convention
  • B) Because low-effort items should be prioritized higher since they provide the best return on investment
  • C) Because high-effort items should be ignored entirely
  • D) Because effort is inversely correlated with risk
Answer **B) Because low-effort items should be prioritized higher since they provide the best return on investment.** Inverting the effort score means that items with the same cost-of-delay and risk but lower effort will have higher priority scores. This reflects the Quick Wins principle from the effort-impact matrix: low-effort, high-impact items should be addressed first (Section 34.5).

Question 24

What is an "abstraction deficit" in the context of AI-generated code?

  • A) Not enough abstract classes in the codebase
  • B) Multiple concrete implementations that share similar structure but lack a common abstraction they should share
  • C) Too many levels of abstraction making code hard to follow
  • D) The AI's inability to understand abstract concepts
Answer **B) Multiple concrete implementations that share similar structure but lack a common abstraction they should share.** Because AI generates code one prompt at a time, it solves immediate problems but rarely identifies abstractions that would benefit the overall codebase. Over time, the codebase accumulates concrete implementations that should share a common abstraction but do not (Section 34.2, Pattern 5, and Section 34.4).

Question 25

Which of the following represents the correct "Five Habits of Healthy Codebases" from the chapter?

  • A) Fast builds, high coverage, no bugs, happy developers, clean code
  • B) Regular debt identification, quantitative measurement, deliberate prioritization, continuous improvement, stakeholder communication
  • C) Daily standups, sprint reviews, retrospectives, backlog grooming, release planning
  • D) Unit testing, integration testing, load testing, security testing, acceptance testing
Answer **B) Regular debt identification, quantitative measurement, deliberate prioritization, continuous improvement, stakeholder communication.** These five habits form the foundation of long-term codebase health: regular identification (monthly), quantitative measurement (automated metrics), deliberate prioritization (not just firefighting), continuous improvement (Boy Scout Rule), and stakeholder communication (quarterly debt reports) (Section 34.10).