Low-Level Design Tutorial with Examples.
Low-level design tutorial: object-oriented design with SOLID principles, design patterns, UML, class modelling and LLD interview problems.
Also known as Design Patterns.
Beginner
Start here — no prior experience needed
Why Class Design Matters: A Naive Vending Machine vs a Designed One
A vending machine that lets stock go negative, then one that refuses cleanly — the smallest demonstration of why encapsulation is LLD's first move.
Design a Vending Machine as a State Machine
Model IDLE, HAS_MONEY, DISPENSING, and SOLD_OUT as explicit states instead of scattered booleans, and watch invalid transitions get rejected by name.
Design Tic-Tac-Toe: Board, Players, and Win Detection
Split a game into a Board that only knows about cells and a Game that only knows about turns, then check all eight winning lines after every move.
SOLID in Practice: The Open/Closed Principle
An if/elif area calculator silently drops a new shape's area to zero; a polymorphic one sums it correctly with zero changes to the calculator itself.
Intermediate
For developers with core concepts down
Design a Parking Lot: Allocating and Freeing Spots
A motorcycle, a car, and a bus compete for three spot sizes — best-fit allocation, a full-lot rejection, and freeing a spot back for reuse.
Design an Elevator System: Scheduling Requests
Two floor requests, one elevator, and a nearest-request scheduler that has to decide which to serve first and print every floor it passes on the way.
Design a Library Management System: Borrowing and Returning Books
Real date arithmetic decides whether a returned book is late and what the fine is — not a string comparison, and not a guess.
Design an Expense-Splitting App: Balances and Minimal Settlements
Three people, two shared expenses, and a greedy algorithm that settles every balance to zero in the fewest possible payments — not one payment per expense.
Design a URL Shortener: Sequential Codes vs Real Hash Collisions
Two ways to shorten a URL — a base62 counter that never collides but leaks a pattern, and a hash that needs real collision handling.
Wrapping Objects: Adapter, Facade, and Proxy in Python
Fix a mismatched payment SDK with an Adapter, hide a five-step order behind a Facade, and cache a slow service with a Proxy, with real Python output.
The Composite Pattern in Python: Sizing a File Tree Without isinstance
Watch an isinstance-based folder size silently miss a new node type, then fix it with the Composite pattern: one size() that files and folders share.
The State Pattern in Python: Refactoring a Vending Machine Into State Classes
Add a maintenance state to a string-checked vending machine and watch a coin vanish, then move each state into its own class with the State pattern.
Undo and Redo in Python: the Memento and Command Patterns Compared
Break a naive undo with one mid-text edit, then build undo with Memento snapshots and with Command objects, and measure what each one costs in memory.
Chain of Responsibility in Python: Expense Approvals Without an if/elif Ladder
Add a rule to an if/elif approval ladder and watch it never fire, then rebuild it as a Chain of Responsibility where each handler approves or passes on.
Advanced
Production-grade patterns for experienced engineers
Concurrency in LLD: A Real Race Condition in the Parking Lot, Then the Fix
Two threads check the same spot, both see it free, and both take it — a real double-booking bug reproduced on purpose, then closed with a threading.Lock.
The Observer Pattern in Practice: A Stock Ticker Notifying Multiple Displays
AlertDisplay is fully coded but never called — the naive ticker forgot to wire it in. The Observer pattern makes that omission structurally impossible.
Design Patterns That Are Just Language Features: Strategy, Command, Iterator
Strategy becomes a function, Command a closure, Iterator a generator, run in Python, Java 21 and Go 1.23, with the cases where the class should stay.
Abstract Factory and Prototype in Python: Matching Families and Cloning Objects
Fix a dark dialog paired with a light button with one Abstract Factory per theme, then clone costly objects with Prototype and avoid shallow copies.
Also part of Low-Level Design
Taught in other topics. Each link opens the lesson in its home topic.
SOLID Principles in Java
Learn the five SOLID design principles by running Java examples: each shows the violation, what breaks, and the refactor that fixes it.
Composition vs Inheritance in Java
Learn when to favour composition over inheritance, how to use the Decorator and Strategy patterns, and how to build flexible, loosely coupled Java classes.
Design Patterns in Java
Learn the most important Gang of Four design patterns with production-grade Java implementations — Singleton, Factory, Builder, Observer, and Strategy.
Python Design Patterns
Run singleton, factory, observer, strategy, decorator and command patterns in idiomatic Python, and see where functions and modules replace classes.
Design Patterns in TypeScript
Singleton, Factory, a typed registry, a type-state Builder, Strategy and Observer in TypeScript, each run with real tsc errors and tsx output.
JavaScript Design Patterns
Runnable JavaScript design patterns — Module, Singleton, Observer, Factory and Command — each shown with real Node output and the problem it solves.
Design Patterns in C#
C# design patterns by example: Singleton with Lazy<T> and DI lifetimes, Repository, a hand-rolled Mediator, Decorator for caching, and Strategy.
Design Patterns in C++
C++ design patterns run for real: CRTP, mixins, policy-based design, a PIMPL build and its destructor trap, Observer, Factory, thread-safe Singleton.
Design Patterns in Go
Idiomatic Go patterns run for real: functional options, HTTP middleware chains, a repository interface, constructor injection with a fake, and events.
Design Patterns in Rust
Implement idiomatic Rust design patterns — builder, newtype, typestate, RAII guards, strategy closures and observers — as complete runnable programs.
Abstract Classes in Java
Master abstract classes — when to use them over interfaces, template method pattern, and how they enable shared behaviour across a class hierarchy.
Sealed Classes and Interfaces in Java
Learn sealed classes and interfaces (Java 17+) by running them: permits, final vs non-sealed subtypes, exhaustive switch, record patterns and guards.