๐Ÿ Design Patterns with Python
Home Chapters Examples Diagrams Bibliography GitHub โ†—
  1. Home
  2. Changing Inherited Code
Part 11 4 chapters

Changing Inherited Code

Seams in Python, dependency-breaking techniques, Fowler and Feathers contrasted and combined, and the decision between refactoring and rewriting.

Chapter 33

Seams in Python: monkeypatch, injection, and duck typing

Find the places in code you didn't write where a test can swap a dependency without editing it, and learn where a patch has to land for the swap to take effect.

Read โ†’
Chapter 34

Dependency-breaking techniques for modern Python

Break a legacy engine's hard-wired carrier calls one small step at a time, and use a single table of expected quotes to show that no step changed what the code does.

Read โ†’
Chapter 35

Fowler vs Feathers, contrasted and combined

See what each book assumes before you touch code, record what an inherited engine really quotes, and refactor it in small steps while a table of those quotes tells you the moment a total moves.

Read โ†’
Chapter 36

Refactor or rewrite

Decide between reworking an inherited engine and replacing it from the forces in front of you, prove a rewrite matches the old quotes before it takes traffic, and route one zone at a time.

Read โ†’
โ† Previous part Patterns in the Wild Next part โ†’ Concurrency
Design Patterns with Python
Prose, diagrams and decks: CC BY 4.0. Sample code: Apache 2.0.
Source on GitHub โ†—  ยท  File an issue โ†—