What and Why

Refactoring is the practice of changing the internal structure of code without changing its observable behavior. You're not adding features. You're not fixing bugs. You're improving the code to make future changes easier.

You encounter refactoring constantly: when the code you need to modify is tangled, when extending a function requires understanding three other functions first, or when a six-month-old decision has calcified into technical debt you can no longer route around.

Refactoring isn't cleanup for its own sake — it's a prerequisite for velocity. Code that's hard to understand is slow to change and prone to bugs on modification. Teams that never refactor slow down measurably as the codebase grows.


Core Concepts

Why does code rot if you never touch it?

Every piece of code was written under specific assumptions — about how the system would grow, what requirements would stay stable, and what the team would look like. Those assumptions change. Code doesn't.

In the full tutorial

  • How It Works in Practice
  • Common Mistakes
  • Tradeoffs
  • Quick Reference

Glossary history

Click dotted jargon to save explanations here.