Refactoring Lab

One requirement change, priced under the structure before a restructuring and the structure after it — with what the better-looking design gave up. Every entry carries that cost, because a before-and-after that only showed the win would be an advertisement.

A restructuring is only an improvement relative to a change you expect. So each entry starts from the change, lists the modules and tests that move on each side, and then names what was traded: indirection, a vocabulary the reader must learn, a migration, an extra hop, a boundary that is now a contract somebody has to maintain. If you cannot say what a refactoring cost, you have not finished thinking about it — and the version of this page that omitted the cost column would teach the exact habit the domain is trying to break.

80 of 80 before-and-afters
Where this is taught
Price the change, not the code
Add VAT to European orders
The change

Prices shown and charged must include VAT for customers in the EU, at a rate that depends on the country and the product category.

Price computed inline wherever it is needed
CheckoutControllerCartViewOrderSummaryEmailInvoicePdfAdminOrderListRefundServiceExportJobPriceApiSubscriptionRenewal
testscheckout_testcart_testemail_testinvoice_testadmin_testrefund_testexport_testprice_api_testrenewal_test
9 modules · 9 test files

Nine sites, nine test files, and no way to know they now agree except by reading all nine. The expensive part is not the edit — it is establishing that the ninth site was the last one.

A single pricing module owns "what does this cost"
Pricing
testspricing_testcheckout_integration_test
1 module · 2 test files

One edit, one focused test suite, plus one end-to-end check that the displayed price still equals the charged price. Discovery cost is zero because the rule has an address.

what it cost Every caller now depends on the pricing module, so it has nine dependents and becomes a coordination point: two teams changing pricing in the same sprint now conflict where before they edited different files. The extraction also cost a risky refactor of working code, and it does nothing for a change to how prices are *stored*.
modules before
9
modules after
1
test files before
9
test files after
2