Skip to content
LLD Learn/Welcome to LLD Fundamentals
Browsing as a guest. Sign in to save your progress and earn XP as you complete chapters.

The LLD Interview Framework

6 min read

You'll learn to

  • -Follow a repeatable five-step process: clarify, find actors and use cases, design classes, apply patterns only where they earn their place, then discuss trade-offs
  • -Turn the nouns and verbs of a requirement into classes and methods
  • -Recognize the three failure modes that sink most answers: over-engineering, ignoring concurrency, and treating the diagram as the finish line
  • -Walk a small example (a vending machine) through all five steps

Tip: the highlighter is on - just select any text below to mark it. Use the highlighter button up top to change color or turn it off. Highlights are saved on this device only. Log in to save them to your account instead.

Every strong LLD answer follows roughly the same five-step shape, whether the prompt is "design a parking lot" or "design an elevator system". LLD stands for Low-Level Design: deciding which classes a program needs, what each one is responsible for, and how they work together. A framework does not make your answer formulaic. It frees your attention to think about the actual problem instead of the process, which is exactly what a 45-minute clock demands.

An Analogy: An Architect Before the First Drawing

A good architect does not start by drawing a staircase. They first ask how many people will live in the house and what the budget is. Then they ask who uses which room. Only after that do they sketch a floor plan, choose standard fixtures where they fit, and check how easily a room could be added later. The five steps below are the same sequence applied to code.

  • -Asking about the household and the budget is clarifying requirements.
  • -Asking who uses which room is finding the actors and their use cases.
  • -The floor plan is the set of classes and the relationships between them.
  • -Standard fixtures are design patterns: ready-made answers to common problems, used only where the house needs them.
  • -Checking how to add a room later is discussing extensions and trade-offs.

Do not worry if some words here are new. A class is a blueprint for objects that hold data and the actions that use it. A use case is one thing a person wants to do with the system. Concurrency means two things happening at the same time, such as two cars arriving at the last parking spot together. Each idea gets its own chapter, and for now the one-line meaning is enough.

The Five Steps

  • -Clarify requirements. What must the system do (functional requirements), and what limits does it work under (scale, concurrency, extensibility)? Write them down where the interviewer can see them.
  • -Identify actors and use cases. Who or what interacts with the system, and what are the three to five core things each of them does?
  • -Design classes and relationships. Nouns become classes and verbs become methods. For each pair of classes you decide how they relate: one uses the other, one owns the other, or one is a kind of the other.
  • -Apply patterns where they earn their cost. A pattern should solve a concrete problem you can name, not be added to show you know its name.
  • -Discuss trade-offs and extensions. What changes if a new requirement shows up? Where are the seams in your design that make that change cheap?

A Worked Example: A Vending Machine

Take the prompt "design a vending machine". A later case study builds it in full. Here we only watch how the five steps shape the first ten minutes.

  • -Step 1, clarify. Which coins and notes? One kind of product per slot? What happens when a product sells out, or the machine cannot make change? One customer at a time? Suppose the answers are coins only, one product per slot, a refund when a product is unavailable, and one customer at a time.
  • -Step 2, actors and use cases. The customer inserts money, selects a product and can cancel for a refund. The operator restocks slots and collects cash. That is five actions, which is plenty.
  • -Step 3, classes. Underline the nouns: machine, product, slot, coin. Underline the verbs: insert, select, dispense, refund. The sketch below shows how they map. A slot exists only as part of its machine, so the machine owns its slots.
  • -Step 4, patterns. The machine acts differently when it is idle, holding money, or dispensing. That is a real, named problem, so the State pattern earns its place here. Nothing in the requirements asks for a Factory or an Observer, so we add neither.
  • -Step 5, extensions. If asked about promotional discounts, point at the one place where a price is calculated and show that only that class changes.
Step 3: nouns become classes, verbs become methods (the bodies come later)
class Product:                          # a noun from the requirements
    def __init__(self, name, price_cents): ...

class Slot:                             # a noun: holds one kind of product
    def __init__(self, product, quantity): ...

class VendingMachine:                   # the noun that owns the others
    def insert_coin(self, cents): ...   # verbs become methods
    def select(self, slot_id): ...
    def cancel(self): ...

The Failure Modes That Actually Sink Candidates

Over-engineering is the most common one. It means reaching for Factory, Strategy and Observer in the first five minutes on a problem that does not need any of them yet, because the requirements have not given a reason.

The second is ignoring concurrency. Many classic prompts, such as parking-lot spot assignment, movie seat booking and rate limiters, are secretly concurrency problems, and a design that never mentions thread-safety has missed half the point.

The third is treating the class diagram as the finish line instead of the midpoint. Interviewers almost always follow up with "now add X", and a design that cannot absorb that follow-up without a rewrite has failed the real test, even if the first diagram looked clean.

Do not introduce a design pattern before the requirement that justifies it exists. "I'll use Strategy here" is a red flag on its own. "I'll use Strategy here because we need to swap pricing rules at runtime without touching the booking class" is the same code with the reasoning that actually matters.

Interview Signal

You finish your class diagram for a vending machine with 10 minutes left. The interviewer asks: "What if we now need to support promotional discounts?"

Weak Answer

"I'd add an if-statement in the checkout method that checks for a discount code and reduces the price."

Strong Answer

"I'd introduce a DiscountStrategy interface with implementations like PercentageDiscount and FixedAmountDiscount, and have the machine hold a reference to the active strategy. That keeps the checkout logic unchanged and means new discount types never require touching existing code - which is exactly the kind of extension this design should already be built for."

Check Yourself1 / 5

In the five-step LLD framework, what comes immediately after clarifying requirements?

Discussion0

Join the Discussion

Sign in to leave comments, reply to others, or like insights.

Sign In to ScaleDojo

No comments yet. Be the first to start the thread!