Category: Code Principles
What Is the LRU Cache Eviction Policy?
The Least Recently Used (LRU) cache eviction policy is one of the oldest, simplest, and most trusted ideas in computer science: when a fixed-size cache runs out of space, throw away whichever item has gone the longest without being touched. Under that one-line rule sits a surprisingly deep piece of…
What Is the DRY Principle?
A calm, thorough guide to DRY (“Don’t Repeat Yourself”): the misplaced-home-address analogy, the formal definition centered on knowledge rather than text, its 1999 origins with Andy Hunt and Dave Thomas in The Pragmatic Programmer, the playful WET opposite, the three kinds of duplication (code, logic, knowledge/data), a building-blocks diagram of…
What Is the KISS Principle?
A calm, thorough guide to KISS (“Keep It Simple, Stupid”): the three-button-vs-forty-two-button remote analogy, the formal definition (a test not a ban), its origin around 1960 with Kelly Johnson at Lockheed’s Skunk Works and later adoption by the U.S. Navy, the crucial simple-vs-easy distinction, a building-blocks diagram of a six-part…
What Is the YAGNI Principle?
A calm, thorough guide to YAGNI (“You Aren’t Gonna Need It”): the overstuffed-suitcase and lemonade-stand analogy, the formal definition (build for confirmed present need, not guessed future need), its Extreme Programming origins with Kent Beck, Ron Jeffries and the Chrysler C3 payroll project, the four hidden costs of building early…
Why Can Deep Inheritance Hierarchies Be Problematic?
A complete guide to why deep inheritance hierarchies become problematic in software design: the tall-apartment-building analogy, an honest look at what counts as “deep” (1-2 / 3-4 / 5+ levels), the four core problems (fragile base class amplified, the yo-yo problem, compile-time rigidity, leaky encapsulation), a step-by-step walkthrough of a…
What Is the Liskov Substitution Principle?
A complete guide to the Liskov Substitution Principle: what it says, the hidden contract of preconditions/postconditions/invariants, the classic Rectangle-Square trap, everyday violations (birds, files, payments), how to spot them, how to fix them (split abstractions, favour composition), and how LSP interlocks with the other SOLID principles.
What Is the Open/Closed Principle?
Add new behaviour without touching what already works. That is the whole promise of the Open/Closed Principle — the “O” in SOLID. This thirteen-chapter guide unpacks the formal definition from Bertrand Meyer, what “open” and “closed” each really mean, why it matters, four reliable warning signs of a violation, a…
What Is the Single Responsibility Principle?
One class, one job, one reason to change. It sounds almost too simple to matter — until you see what happens to a codebase when nobody bothers to follow it. This thirteen-chapter guide takes a deep dive into the “S” in SOLID: the formal definition from Robert C. Martin, what…
What Does SOLID Stand For?
Five short letters — S, O, L, I, D — five simple habits, and decades of hard-won wisdom about writing code that does not fall apart the moment it needs to grow. This thirteen-chapter guide walks through what each letter really means in plain language: Single Responsibility, Open/Closed, Liskov Substitution,…