Changing Inherited Code (Modernized Feathers)
Seams and the test safety net, the dependency-breaking techniques updated for Java 25, Fowler contrasted and combined with Feathers, and when to refactor versus rewrite.
Seams and the test safety net
Getting a hard-wired shipment escalation service and a risk scorer under test before changing them. Characterization tests pin the current behavior, an object seam and an extract-interface seam make the escalation service's clock and gateway substitutable, and a subclass-and-override seam opens the risk scorer with no constructor change.
Dependency-breaking techniques for Java
Michael Feathers' dependency-breaking techniques in modern Java, on a hard-wired LegacyShipmentProcessor: Extract Interface with Parameterize Constructor opens a seam around a concrete mail dependency, Extract and Override Factory Method around an embedded surcharge calculator, Subclass and Override Method around a wall-clock read, and Adapt Parameter shrinks a manifest-file parameter to the two values a caller reads.
Characterization tests; Fowler vs Feathers
Characterization tests lock in the behavior of an inherited freight-quote calculator before anyone understands it. Fowler's Refactoring assumes that safety net exists, Feathers' Working Effectively with Legacy Code builds it, and the two run in sequence on one calculator.
Refactor, rewrite, or strangler fig
Choosing between an in-place refactor, a wholesale rewrite and the strangler fig, on a legacy accessorial fee calculator with an undocumented renegotiated fuel rate, a weight-based fee waiver and a carrier-specific oversize penalty. A strangler router sends each shipment to the legacy or modern calculator behind one AccessorialFeeCalculator interface, and a shared characterization table proves the two agree before cutover.