principle-solid
Installation
SKILL.md
SOLID
Five heuristics for OO design. Guidelines, not laws.
S — Single Responsibility
A module should have one reason to change. Usually that means one actor it serves.
- Good:
InvoiceCalculatorcomputes totals;InvoiceRendererformats output. - Bad:
Invoicethat calculates, renders, emails, and persists. - Misapplied: splitting a 20-line class into five 4-line classes. SRP is about change vectors, not line count.
O — Open-Closed
Open for extension, closed for modification. New behavior should not require editing stable code.
- Good: a payment processor iterates
PaymentMethodimplementations; new methods are new files. - Bad: a giant
switchonpaymentTypethat every new method edits. - Misapplied: introducing a plugin framework for three enum values that will never grow.