Part 10 4 chapters

Changing Inherited Code (Modernized Feathers)

Seams and the test safety net, the 24 dependency-breaking techniques updated for C++20/23, Fowler contrasted and combined with Feathers, and when to refactor versus rewrite.

Chapter 27

Seams and the test safety net

Getting inherited C++ under test before changing it: characterization tests pin a shipment-SLA checker that reads the wall clock, an object seam makes the clock substitutable so the deadline boundary can be pinned and corrected, and a link seam replaces a free function's grace-period policy at link time.

35 minRead โ†’
Chapter 28

The 24 dependency-breaking techniques for C++20/23

Michael Feathers' 24 dependency-breaking techniques mapped to modern C++, then applied to inherited shipping code: a mail dependency behind an interface and a defaulted constructor parameter, a clock read isolated into an overridable call, a mutable global behind an accessor, a static lookup behind an instance delegator, and a file-parsing parameter adapted down to the two values a caller reads.

35 minRead โ†’
Chapter 29

Fowler and Feathers: contrasted and combined

Martin Fowler's Refactoring and Michael Feathers' Working Effectively with Legacy Code compared on an inherited shipping ETA estimator, then run in sequence: Feathers first to build a safety net, Fowler next to apply named refactorings, with every test green at each step.

35 minRead โ†’
Chapter 30

Refactor or rewrite

Choosing between incremental refactoring and a bounded rewrite, taught against a legacy freight-pricing engine with an undocumented zone-rate matrix, two undocumented customer overrides and an unexplained rounding rule. A strangler fig router replaces it behind a stable PricingEngine interface, customer by customer, after a shared characterization table shows the new engine agrees with the old.

30 minRead โ†’