Low-Level Design
SOLID principles, design patterns, OOP, and real LLD interview questions with class designs.
Foundations
What is Low-Level Design?
Understanding what LLD is, how it differs from HLD, and what interviewers expect in an LLD round.
OOP: The Four Pillars
Encapsulation, Abstraction, Inheritance, and Polymorphism -- the foundation of object-oriented design.
Composition vs Inheritance
Why we should favor composition over inheritance, and when each approach makes sense.
Abstract Classes vs Interfaces
When to use an abstract class and when to use an interface -- and why it matters in LLD.
SOLID Principles
Single Responsibility Principle (SRP)
A class should have only one reason to change -- the first and most important SOLID principle.
Open/Closed Principle (OCP)
Software entities should be open for extension but closed for modification.
Liskov Substitution Principle (LSP)
Subclasses should be replaceable for their parent class without breaking anything.
Interface Segregation Principle (ISP)
Don't force classes to implement interfaces they don't use -- keep interfaces small and focused.
Dependency Inversion Principle (DIP)
Depend on abstractions, not concrete implementations -- the key to flexible, testable code.
Design Principles
DRY, KISS, and YAGNI
Three timeless principles that keep our code simple, clean, and focused.
Coupling and Cohesion
Why we want low coupling between classes and high cohesion within them.
UML Class Diagrams
The quick visual language we use in LLD interviews to show class relationships.
Creational Design Patterns
Singleton Pattern
Ensuring only one instance of a class exists, with a global access point.
Factory Pattern
Creating objects without specifying the exact class, using Factory Method and Abstract Factory.
Builder Pattern
Building complex objects step by step with a clean, readable interface.
Prototype Pattern
Creating new objects by cloning existing ones instead of building from scratch.
Structural Design Patterns
Adapter Pattern
Making incompatible interfaces work together by wrapping one with a compatible interface.
Decorator Pattern
Adding behavior to objects dynamically by wrapping them, without modifying the original class.
Facade Pattern
Providing a simple interface to a complex subsystem so clients don't need to know the messy details.
Proxy Pattern
Controlling access to an object through a surrogate that adds lazy loading, access control, or caching.
Behavioral Design Patterns
Observer Pattern
One-to-many dependency where one object changes and all its dependents get notified automatically.
Strategy Pattern
Define a family of algorithms, encapsulate each one, and swap them at runtime without changing client code.
Command Pattern
Encapsulate a request as an object to parameterize, queue, log, and undo operations.
State Pattern
An object changes its behavior when its internal state changes, as if it switched its class.
Template Method Pattern
Define the skeleton of an algorithm in a base class and let subclasses override specific steps.
Real LLD Questions
Design a Parking Lot
Complete LLD for a multi-floor parking lot with ticketing and payment.
Design an Elevator System
Complete LLD for a multi-elevator system with scheduling algorithms and state management.
Design BookMyShow
Complete LLD for a movie ticket booking system with seat locking and concurrency handling.
Design a Vending Machine
Complete LLD for a vending machine using the State pattern with inventory and change management.
Design Snake & Ladder Game
Complete LLD for a turn-based Snake & Ladder game with board, players, and dice.
Design Chess Game
Complete LLD for a chess game with polymorphic piece movement, board management, and game rules.
Design Library Management System
Complete LLD for a library system with book catalog, member management, borrowing, and fine calculation.
Design ATM Machine
Complete LLD for an ATM system with state-driven flows, authentication, cash dispensing, and transactions.