OrderService
+ calcTax() ⧉
CartService
+ calcTax() ⧉
DRY — one source of truth
1class OrderService { int calcTax(){ /* … */ } } // copy2class CartService { int calcTax(){ /* … */ } } // paste34// extract the shared knowledge:5class TaxCalculator { int calc(){ /* … */ } }6// OrderService + CartService now depend on it
State
calcTax()lives in 2 places