Briefle words · Code & architecture
DRY
Also called Don't Repeat Yourself
The principle that each piece of logic should be written in exactly one place, not copied around.
Say it to an AI
TypeScript monthlyPrice and yearlyPrice (yearly = 10 months) for a plan, including VAT. Keep it DRY: both call one private helper, withVat(amount, country), that looks the rate up in a VAT_RATES map and rounds to cents, so no tax logic is duplicated.
How an expert would brief the stronger version of “Subscription prices”.
See it
Try it as a puzzle →Pricing code that shows monthly and yearly plan prices, with VAT, on a video streaming service.
Why: B's VAT lookup and rounding exist only in 'withVat'; A copies the rate lookup, the multiply and 'Math.round(price * 100) / 100' twice.
Related words
Room 1 · Essentials
Learn “DRY” in a five-minute lesson