Concept · Intro

DRY · KISS · YAGNI

Three everyday rules that keep designs lean — Don’t Repeat Yourself, Keep It Simple, You Aren’t Gonna Need It.

Asked atAmazonGoogleBasecamp
step 1 / 7
1/2DRY — one source of truth
OrderService
+ calcTax() ⧉
CartService
+ calcTax() ⧉
DRY — one source of truth
1class OrderService { int calcTax(){ /* … */ } } // copy
2class CartService { int calcTax(){ /* … */ } } // paste
3 
4// extract the shared knowledge:
5class TaxCalculator { int calc(){ /* … */ } }
6// OrderService + CartService now depend on it
State
calcTax()lives in 2 places

OrderService and CartService each carry their OWN copy of calcTax(). The ⧉ marks duplicated knowledge — the same tax rule pasted in two places.