Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

What is LLD?
LLD

What is LLD?

Introduction to Low-Level Design, its purpose, scope, and role in software development.

The Gap It Fills

A team receives an HLD: “Order Service calls Payment Service, backed by Postgres.” The first developer opens the IDE and invents fifteen classes ad hoc. Three weeks later, adding UPI payments touches eleven files because payment logic leaked into orders, notifications, and the controller. Nobody designed the inside of the boxes — that inside design is Low-Level Design.

LLD converts one component of an HLD into a class-level blueprint: concrete classes, interfaces, fields, exact method signatures, relationships, state transitions, and invariants — enough detail that implementation requires zero further design decisions.

Position in the Stack

Requirements ────► HLD ──────────► LLD ─────────► Code
  WHAT              HOW (macro)     HOW (micro)
 features          services        classes
 scale targets     storage choice  method contracts
 SLAs              queues, caches  relationships
                                   invariants

Read left to right, each stage answers a narrower question. HLD decides which services exist and how they talk; LLD decides what’s inside one service. A mistake at the HLD stage costs a migration; a mistake at the LLD stage costs a refactor. Both stages exist because mixing the two questions produces neither a scalable system nor readable code.

Scope Boundaries

In Scope (LLD)Out of Scope (HLD territory)
Class & interface identificationService topology
Fields + exact method signaturesDatabase engine selection
Relationships & multiplicitiesLoad balancing, sharding
Design pattern applicationCapacity estimation
Concurrency within one processCross-service consistency
Error model of a componentAPI gateway design

The boundary blurs in practice — a monolith team’s “HLD” may be another team’s “LLD.” What matters is decision granularity, not document names.

Standard Interview Format (35–45 min)

  • 0–5 min: Requirements clarification — lock functional core + constraints.
  • 5–20 min: Entities, relationships, class diagram.
  • 20–35 min: Core slice implemented in code (Java/C++/Python).
  • 35–45 min: Follow-ups — new feature, concurrency, scale twist.
  • Canonical problems: Parking Lot, Elevator, BookMyShow, Splitwise, Vending Machine, Chess, LRU Cache, single-node Rate Limiter.

Rubric Axes

AxisJunior signalSenior signal
ModelingClasses mirror nounsResponsibilities assigned; verbs become methods on owners
ExtensibilityWorks for stated caseSurvives the unstated follow-up
PatternsStuffs patternsDeletes unneeded patterns; justifies each
StatePublic fields, setters everywhereInvariants enforced at construction and mutation
ConcurrencyIgnored until askedNames shared mutable state unprompted

Failure Modes

  • Coding at minute 5: solves the wrong problem completely and elegantly.
  • God class (ParkingLotManager owning tickets, slots, pricing, payments): fails every extensibility follow-up.
  • Anemic domain: XService classes hold all logic; entities are field bags — interviewer reads it as no OO depth.

The Problem It Addresses

Software decays even when nobody touches requirements. Month one: feature ships in a day. Month twelve: the same-sized feature takes a sprint and breaks two unrelated flows. Nothing changed except accumulated accidental structure — classes entangled through shortcuts taken when “there was no time to design.” Maintenance consumes 60–80% of total software lifecycle cost (Boehm’s cost model, replicated across industry studies), and code is read roughly 10× more often than written — so design quality is primarily a read-time property.

Cost to add feature N+1
 ▲                              ╱ no deliberate design:
 │                          ╱╱   every change touches
 │                      ╱╱        everything (tangles grow)
 │                 ╱╱───────────── deliberate design:
 │           ╱╱╱                    bounded blast radius,
 │      ╱╱╱                         new code plugs into seams
 └──────────────────────────────────────► time / feature count

The curves are illustrative, not measured benchmarks — but the divergence mechanism is mechanical: each undisciplined change adds edges to the dependency graph, and edit cost tracks edges touched.

The Six Goals

GoalDefinitionMechanism that delivers it
CorrectnessValid states onlyInvariants enforced at construction + mutation points
ExtensibilityAdd features without editing coreProgram to interfaces; Open-Closed
MaintainabilityChange one thing, break nothingHigh cohesion, low coupling
TestabilityUnit-test without infrastructureDependency injection creating seams
ReusabilityOne implementation, many callersComposition over inheritance
CommunicationDiagram = enforceable team contractUML class/sequence diagrams

No design maximizes all six simultaneously — an interface for everything buys extensibility at the cost of simplicity. Deliberate LLD is choosing which goals this component needs.

Defect Economics

Fix cost grows roughly an order of magnitude per phase (requirements → design → code → production): a flaw caught in design review costs minutes; the identical flaw reaching production costs an incident plus rollback. LLD review is the cheapest place defects ever get caught.

Why Interviews Test It

  • LLD performance predicts daily-job refactoring ability far better than memorized patterns do.
  • It resists cramming: a follow-up (“now support multiple floors”) instantly exposes copied designs.
  • It tests vocabulary precision — a candidate who says “use a factory here” but cannot name what varies fails the bar.

What Good Looks Like

  • Every class answers: what state do I own, which invariants must hold, which requests can I serve?
  • Adding a feature means adding classes/methods, not editing existing ones (Open-Closed in practice).
  • No class exceeds a few hundred lines before responsibilities leak — beyond that cohesion is gone.

Failure Modes

  • Pattern stuffing: Strategy + Factory + Builder for a three-class problem — indirection must earn its cost.
  • Premature generality: interfaces with exactly one implementation and no test-seam purpose — YAGNI noise for reviewers.
  • Design amnesia: clean whiteboard diagram, code diverges from it immediately — reviewers check they agree.

My Private Notes

Notes are auto-saved locally to this device.