๐Ÿณ IntuitiveFE
Login
โ† All concepts

Tech Debt & Stack Migrations

โฑ๏ธ ~4-minute bite ยท solve the sandbox to master

0%lesson
๐Ÿง’

5-Year-Old Metaphor

โ€” The physical, real-world picture. No jargon.

๐Ÿ’ณ Tech debt = credit card debt. Some is strategic. All of it has interest. The strangler fig = renovating a building while it's occupied.

The debt metaphor

Ward Cunningham coined "technical debt" to explain why rushed code is a borrowing: you get speed now and pay in slower future development. The interest is paid every time a developer touches that area โ€” extra time to understand, work around, or fix accidental complexity.

Some debt is strategic: you know a better approach but choose the fast one with a explicit payback plan. That's like using a mortgage โ€” not inherently bad. Reckless debt โ€” taking shortcuts without awareness or plan โ€” is like credit card debt at 30% APR.

When to migrate now

  • โ€ข Debt is slowing every feature in that area
  • โ€ข Security or compliance risk
  • โ€ข Key dependencies end-of-life
  • โ€ข On-call burden is unsustainable

When incremental is fine

  • โ€ข Code works, just inelegant
  • โ€ข Area rarely touched
  • โ€ข No clear migration target yet
  • โ€ข Team has more urgent priorities
๐ŸŽ›๏ธ

Interactive Sandbox

โ€” Move something, see it react instantly.

Migration Strategy

Risk

Low โ€” framework only

Timeline

Ongoing

Steps

5

Scenario: Team is deciding whether to take on debt to meet a deadline

Migration steps

  1. 1.Deliberate + Reckless: 'We don't have time to design this properly' โ€” pure negligence. Avoid.
  2. 2.Deliberate + Prudent: 'Ship now, we know we'll refactor the auth layer in Q3' โ€” strategic debt. OK if actually paid back.
  3. 3.Inadvertent + Reckless: 'What's layering?' โ€” lack of knowledge or skill. Address through education and code review.
  4. 4.Inadvertent + Prudent: 'We now know a better approach' โ€” learning debt. Refactor when you encounter it.
  5. 5.Decision: Is this deliberate? Is it prudent? Reckless debt is always wrong. Prudent deliberate debt may be strategic โ€” but write down the payback plan now.
โš ๏ธ Gotcha: Most teams only recognize deliberate reckless debt as 'real' debt. Inadvertent prudent debt (we learned a better way) is equally important โ€” it compounds just as fast if ignored.
๐Ÿ’ก Insight: The business case for debt paydown: each feature that touches indebted code costs extra time (the interest). Measure how long features take in high-debt vs low-debt areas. The delta is the interest rate โ€” this makes debt concrete to non-engineers.
Visited:๐Ÿ—บ๏ธ๐ŸŒฟ๐Ÿค–๐Ÿšฉ๐Ÿงน
๐ŸŽฏ

Challenge

Visit all 5 migration patterns. Understand which strategy to use for different migration scenarios.

Try it
๐ŸŽฏ

Why Should I Care?

โ€” The exact interview question + the bug it kills.

Interview questions

Q: What is Martin Fowler's technical debt quadrant?

Fowler's quadrant has two axes: Deliberate/Inadvertent and Reckless/Prudent. Deliberate+Prudent: conscious strategic shortcut with a payback plan (acceptable). Deliberate+Reckless: "no time to design" (always bad). Inadvertent+Prudent: "we now know a better way" โ€” learning debt (refactor when encountered). Inadvertent+Reckless: "what's layering?" โ€” skill/knowledge gap (address through training and review).

Q: When is a full rewrite justified?

Almost never. Full rewrites are high-risk: you lose battle-tested bug fixes, undocumented edge case handling, and institutional knowledge embedded in the old code. The new system usually ships later than expected and recreates many of the same bugs. The Strangler Fig pattern is almost always preferable โ€” incremental replacement with constant validation. A rewrite is justified when: (1) the runtime/platform is being discontinued, (2) the old codebase is literally unmaintainable (no one alive understands it), (3) a complete domain model change makes incremental migration semantically impossible.

Q: How do you measure tech debt?

Proxy metrics: code duplication (SonarQube), cyclomatic complexity, test coverage by file, dependency age (npm outdated), time-to-onboard new engineers on a module, time-to-implement features vs estimate in high-debt areas. The most honest metric: ask engineers "which files do you dread touching?" โ€” that's where the debt is.

๐Ÿ”ฌ

The Deep Dive

โ€” Spec refs, engine internals, the minutiae.

jscodeshift codemod example

js
1// codemod.js โ€” rename a prop across all usages
2// Before: <Button variant="primary" />
3// After: <Button intent="primary" />
4ย 
5export default function transformer(file, api) {
6 const j = api.jscodeshift;
7 return j(file.source)
8 .find(j.JSXAttribute, { name: { name: 'variant' } })
9 .filter(path => {
10 // Only on Button components
11 return path.parent.value.name.name === 'Button';
12 })
13 .forEach(path => {
14 path.node.name.name = 'intent';
15 })
16 .toSource();
17}
18ย 
19// Run:
20// npx jscodeshift -t codemod.js src/ --extensions=tsx,ts --dry
21// Remove --dry when satisfied with the diff

Migration readiness checklist

โœ“Behavior is covered by tests (you'll know if migration broke something)
โœ“You have metrics to compare old vs new implementation in production
โœ“Rollback path is instant (feature flag or blue/green deploy)
โœ“Data migration is tested with production-representative data
โœ“Dependent systems are identified and their owners notified
โœ“The old system can run in parallel with the new one (no exclusive resource locks)
โœ“You have a clear 'done' definition โ€” when is old code safe to delete?

DORA metrics and tech debt

High-debt codebases have measurable DORA metric degradation: longer lead times (harder to implement features), higher change failure rates (more bugs from unintended interactions), longer MTTR (harder to find and fix issues in complex code). Tech debt paydown shows up as improving DORA metrics โ€” this is the business case in engineering team language.

๐ŸŽค

Interview Questions

โ€” Real questions from real interviews โ€” with answers.

Strangler fig + feature flags let us migrate the checkout service over 8 weeks without a freeze.

Measure the interest rate: extra hours per sprint in high-debt areas vs low-debt areas.

Almost always โ€” strangler fig gives continuous validation; rewrites give you a second system that breaks in new ways.

Carve a seam, add tests on entry, and apply the Boy Scout Rule on every PR that touches it.

Ship at 0%, validate on internal users, roll out by segment, clean up after 2 weeks at 100%.

Deliberate/prudent debt is OK with a written payback plan; reckless shortcuts need to be caught in review.

๐ŸŽฎ

Memory Game

โ€” Quick quiz โ€” lock the concept in long-term memory.
1/4

What is the 'golden path' and how does it relate to tech debt prevention?