LOW LEVEL DESIGN · STEP 3 OF 9

Design principles

The everyday judgement calls: duplication, coupling, wiring dependencies and immutable values. Each lesson is an animated walkthrough with a small Java example you can run, notes and the interview questions with answers.

  1. 1 DRY, KISS and YAGNIThree everyday design rules: keep each piece of knowledge in one place (DRY), choose the plainest design that works (KISS), and do not build for needs you only imagine (YAGNI). Plus when DRY goes wrong: accidental duplication, the wrong abstraction and helpers that grow flags.15 steps · 8 interview Q&As · Java example
  2. 2 Coupling and cohesionWhy good classes know little about each other and keep related things together: the kinds of coupling from loose to tight, the Law of Demeter and tell-don't-ask, high and low cohesion, and a practical test for both: look at what changes together. Shown on a ride-hailing app in Java.14 steps · 8 interview Q&As · Java example
  3. 3 Dependency injectionStop a class from creating its own collaborators and hand them in instead. Covers constructor, setter and field injection and when to use each, wiring everything by hand in main (the composition root), why injected fakes and a fixed clock make tests fast and exact, and what a DI container adds.14 steps · 8 interview Q&As · Java example
  4. 4 Immutability and value objectsObjects that never change after they are built remove a whole family of bugs. Covers final fields, Java records, validation in the constructor, defensive copies of lists, "with" methods that return a new object, equality by value instead of identity, and why immutable objects are safe to share between threads.14 steps · 8 interview Q&As · Java example