In part 1, we go through a reasonable-looking codebase and improve it step by step. While doing so, we introduce a set of rules and build a small catalog of powerful refactoring patterns.
We improve the code in four phases, each with a dedicated chapter: shattering long functions, making type codes work, fusing similar code together, and, finally, defending the data. Each chapter builds on the previous one, so some transformations are temporary. If the code or an instruction feels weird or looks ugly, be patient; it will probably change.