Legacy Code Cookbook

Make Tests Independent
Recipe: Squeezing Juice out of Over-ripe Tests
While any bug or change would cause one test to fail, many changes cause unrelated tests to fail. This happens because each test is testing too much. Learn how to squeeze each test done so that it only has one reason to fail.

Start Fixing a God Class
Recipe: Converting the God Classes’ Pawns to Work Against It
It seems like fixing a God Class requires taking responsibilities off of it. Often that is too hard, because the God Class is surrounded by procedures that lock it in place. Learn how to convert these pawns to your side so that they can help you remove responsibilities later.

Refactor Databases
Recipe: Fixing Databases with Lego
Bad database schemata cause story delays and generate bugs. The common ways to fix schemata take a long time and interrupt story work. Learn how to change schemata with simple and uniform transformations.

Port Between Technologies
Recipe: Creating and Shipping a Chimera
Migrating between technologies is hard. The common approach is to replace the old technology with the new one. Learn how to incrementally change the technology without disrupting your feature progress.

Test Interactions Between Third Party Services
Recipe: Isolating Dependencies with with Ports & Adapters
Verifying integration with a third party service is hard. The common solution is to write end-to-end integration tests. Learn how to create a different kind of integration test that won’t break with unrelated code changes.

Split a God Class
Recipe: Use Data to Split a God Class
It is hard to split responsibilities out of a God Class because the class is so large and complex. It is difficult to identify the many responsibilities and which methods perform which responsibilities. Learn how to use data to mechanically identify responsibilities without needing to understand the God Class.