LOW LEVEL DESIGN · STEP 2 OF 9
SOLID principles
Five rules that keep classes small, swappable and easy to extend. Each lesson is an animated walkthrough with a small Java example you can run, notes and the interview questions with answers.
- 1 Single responsibility principleThe S in SOLID, explained with a meal-plan billing class that calculates, saves and emails all at once. Learn what "one reason to change" really means, how to split the class into a calculator, a store, a mailer and a small coordinator, how to spot the smell, when not to split, and how it shows up in LLD interviews.
- 2 Open/closed principleThe O in SOLID, shown with a courier app whose delivery fees live in a growing switch statement. Learn what open for extension and closed for modification really mean, how an interface plus one class per option lets you add drone delivery without touching tested code, which axis of change to protect, the sealed-type trade-off, and how it appears in LLD interviews.
- 3 Liskov substitution principleThe L in SOLID, shown with notification channels: an SMS sender that rejects long messages and a push sender that silently drops them both break code that trusts the Notifier interface. Learn contracts, why subtypes cannot demand more or promise less, the rules on invariants and exceptions, two ways to fix a broken subtype, and how to spot violations in interviews.
- 4 Interface segregation principleThe I in SOLID, shown with a smart-home hub whose one fat SmartDevice interface forces a plug to fake brightness, temperature and lock methods. Learn why fat interfaces hurt callers and implementers, how to split them into small role interfaces shaped by what each client needs, how far to split, and where the idea shows up in Java and LLD interviews.
- 5 Dependency inversion principleThe D in SOLID, shown with a library late-book reminder that creates its own SQL table and SMS gateway. Learn high-level policy versus low-level detail, why the policy should own the interfaces it needs, what exactly gets inverted, wiring at a composition root, testing with fakes, and how dependency inversion differs from dependency injection and inversion of control.