Foundations · L1Low-level and object-oriented design

Low-level and object-oriented design

Learn a repeatable method for designing the classes of a small system, carried through one parking lot, from the first question to the race at two gates.

L1 Must-knowFoundations20 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 9 Nov 2026 · How we check content
Section 1 of 8

What broke

A made-up story to show a common failure. Not about a real company.

This story is made up, but the pattern is common. Ravi had a 45-minute low-level design round. The prompt was one line: "Design a parking lot."

He started drawing at once. Vehicle got subclasses Car, Bike and Truck. A ParkingLotManager class grew 20 methods: find a spot, print tickets, take payment, send SMS. He added a factory, a singleton and two strategies, to show he knew patterns.

At minute 30 the interviewer asked, "Two cars arrive at two gates at the same moment. Can both get spot 14?" Ravi looked at his code. Both gates read the spot as free, then both took it. He had no answer.

Then came the second question: "We want different prices for trucks." The price logic sat in four methods of the manager. He had to edit all four.

The feedback said: "Knows the patterns. Did not clarify scope. Design breaks under change and under concurrent use." Ravi had written more code than the strong candidates. It was the wrong code.

Section 2 of 8

The idea in simple words

A low-level design (LLD) round gives you a small, self-contained problem. You design its classes, their methods and how they work together. Hello Interview puts it this way: these rounds "test your ability to structure code for a self-contained problem". The round is also called object-oriented design. 1

In a system design round, you draw services, databases and caches for scale. In an LLD round, you design the inside of one program. Hello Interview's summary: "System design is the map. Low level design is the blueprint for a building on the map." 1

Interviewers judge five things: how you analyse the problem, your class design, code quality, how easily the design takes a follow-up change, and how you explain it. 1 Code quality includes choosing composition or inheritance, managing state and the direction of dependencies. 1 Where the round sits in a full loop is in the interview loops lesson.

The key idea. Put each rule in the object that owns the data it needs. Add an interface or a pattern only where you can name a change that is coming. Then ask what happens when two callers touch the same object at once.

You already have the tools. SOLID, coupling and cohesion told you to group what changes together. Design patterns that still matter told you to start from the problem, not the pattern. This lesson is the method that uses both, under time pressure.

Section 3 of 8

How it works

Step through the parking lot design as it grows. Use Next and Back, or the ← and → keys.

A parking lot design grows one step at a time, and one atomic step stops two gates taking the same spotParking lot: classes and who owns what ParkingLotSpotTicketVehicledata: plate, size hasrefers to Vehicle → Car, Bike, Truckno behaviour differs✓ size: S / M / L "Trucks pay more" → a real changePricingPolicyParkingLot calls itHourlyPricingSizePricing Gate AGate BSpot 14both check "free?", then take it ✓ A: true, ticketB: false → next spotcheck and take = one compareAndSetone spot, one ticket SeniorPath
  1. Start from the nouns in your requirements. Four objects matter. Vehicle has no behaviour, so it is just data: a plate and a size.
  2. Draw who owns what. The lot has its spots: that is composition. A ticket only refers to a spot and a vehicle: that is association.
  3. Do not make Car, Bike and Truck subclasses. They differ only in the spot size they need, so a size field is enough.
  4. The interviewer asks for higher prices for trucks. Now pricing has a real reason to change, so the lot calls a small PricingPolicy interface.
  5. Two gates want spot 14 at the same moment. If each first checks 'is it free?' and then takes it, both can win.
  6. Spot.tryTake uses compareAndSet, so the check and the take are one atomic step. Gate A wins. Gate B gets false and tries the next spot.
Step 1 of 6

Hello Interview's framework has five steps, about 35 minutes in total. 2 Here is a version you can repeat.

1. Clarify requirements and scope

The prompt is vague on purpose. Your job is to "turn it into a spec you can actually design around". 2 Spend the first minutes asking. 2

For the parking lot, Hello Interview picks a sample scope. There are three vehicle types: motorcycle, car and large vehicle. Entry gives a free, compatible spot and a ticket. Exit takes the ticket, works out the fee and frees the spot. The price is hourly, rounded up. 3 Payments, gate hardware, cameras, the UI and reservations are out of scope. 3 Say that list out loud. It protects your time.

2. Find the core objects and their responsibilities

Pull out the meaningful nouns from your requirements. 2 For the parking lot: lot, spot, ticket, vehicle. But "don't turn every noun into a class. Some things are just data." 3

Give each object one job, in one sentence:

  • ParkingLot: takes cars in and out, and owns the spots and the active tickets.
  • Spot: knows its size and whether it is taken.
  • Ticket: records which vehicle is in which spot, and since when.
  • Vehicle: just data, a plate and a size.

The framework's rule: "keep rules with the entity that owns the relevant state." 2 Fowler calls the same habit tell-don't-ask: "rather than asking an object for data and acting on that data, we should instead tell an object what to do." 6 So the lot tells a spot "take this ticket". It does not read a taken flag and set it from outside.

3. Choose the relationships

The lot has spots. That is composition: spots belong to the lot. A ticket refers to a spot and a vehicle. That is association: it points at them but does not own them.

Should Car and Truck be subclasses? Only if they behave differently. Here they differ only in size, so a size field is enough. Gamma calls inheritance "a cool way to change behavior", but brittle. A subclass "can easily make assumptions" about when the parent calls the methods it overrides. 9 Here the variants have no behaviour to change. He still backs the GoF advice to favour composition, ten years on. 9

4. Write the interfaces and the few methods that matter

You have about 10 minutes for code. Start with the happy path, then the edge cases. 2 Ask whether they want real code or pseudo-code. 2 Two methods matter here: enter and exit. Like a deep module, they hide the hard parts.

// imports: java.time.*, java.util.*, java.util.concurrent.*, java.util.concurrent.atomic.*
enum Size { SMALL, MEDIUM, LARGE }
record Vehicle(String plate, Size size) {}
record Ticket(String id, Vehicle vehicle, Spot spot, Instant in) {}

final class Spot {
  private final Size size;
  private final AtomicReference<Ticket> holder = new AtomicReference<>();
  Spot(Size size) { this.size = size; }

  boolean fits(Vehicle v) { return size.compareTo(v.size()) >= 0; }
  boolean tryTake(Ticket t) { return holder.compareAndSet(null, t); }
  void release(Ticket t)    { holder.compareAndSet(t, null); }
}

Spot has no public setter. Callers cannot put it into a bad state.

5. Add a pattern only where a change is coming

A common follow-up asks for different prices by vehicle type. 3 Now pricing has a real reason to change, so it earns a small interface:

interface PricingPolicy { long feeCents(Ticket t, Instant out); }

final class ParkingLot {
  private final List<Spot> spots;
  private final Map<String, Ticket> active = new ConcurrentHashMap<>();
  private final PricingPolicy pricing;
  private final Clock clock;
  // constructor that sets all four is left out

  Ticket enter(Vehicle v) {
    for (Spot s : spots) {
      if (!s.fits(v)) continue;
      Ticket t = new Ticket(UUID.randomUUID().toString(), v, s, clock.instant());
      if (s.tryTake(t)) { active.put(t.id(), t); return t; }
    }
    throw new IllegalStateException("no free spot for " + v.size());
  }

  long exit(String ticketId) {
    Ticket t = active.remove(ticketId);
    if (t == null) throw new IllegalArgumentException("unknown or used ticket");
    t.spot().release(t);
    return pricing.feeCents(t, clock.instant());
  }
}

This is the Strategy pattern from the patterns lesson, used for one known need. Before the interviewer asked, a plain hourly method on the lot was enough. Hello Interview warns against a pricing engine with surge prices and discounts "unless they explicitly ask for it". 3

The Clock is passed in, so a test can fix the time. The testing strategy lesson shows why that matters.

6. Handle state and concurrency

Two gates means two threads. Hello Interview describes the classic race for a seat: "Both users checked availability before either completed their booking." 4 The check and the action "happened as two separate steps". 4 This bug is called check-then-act.

The code above makes them one step. compareAndSet sets the new value only if the current value is still the expected one. It returns false if another thread got there first. 11 So one gate wins spot 14. The other moves on to the next spot.

Exit has the same risk. Someone might use one ticket twice. All ConcurrentHashMap operations are thread-safe, and remove returns the old value or null. 10 So only one exit gets the ticket back. Locks, atomics and deadlocks are covered in depth in locks, atomics and deadlocks.

7. Answer the extensibility questions

Expect follow-ups such as many floors, prices by vehicle type, or many entrances. 3 Their goal is to show "that your initial design is extensible and robust". 2 Answer each one by naming the class that changes. Many floors: ParkingLot holds floors, and each floor holds spots. A new price: a new PricingPolicy. If one answer touches five classes, say so and propose a fix.

Section 4 of 8

Trade-offs

ChoiceEasy to change?CostUse it when
A field or enum for the variant (Size)Yes A new size is one value.No place for behaviour that differs.Variants differ only in data.
Subclass per variant (Car, Truck)No Subclasses depend on the parent's details.More classes, brittle hierarchy.Variants really behave differently, and the parent's contract is stable.
Interface plus implementations (PricingPolicy)Yes A new rule is a new class.One more name to learn.You can name a second rule, or the interviewer asks.
Logic in one manager classYes , at first.It grows into a god class. Every change touches it.A first sketch only. Split it before you finish.
Atomic step on the object (tryTake)Yes You must think about which steps must be one.Two callers can change the same object.
One lock around the whole lotYes All gates wait for each other.Low traffic, or a quick first answer you then improve.
Section 5 of 8

At work: how a senior uses this

  • In a design review or a pull request, ask each new class "What is your one job?" If the answer has "and" three times, it needs a split.
  • Watch for a god class: a manager or service that keeps growing. Refactoring.Guru notes that classes "usually start small" but bloat as the program grows. 8 Split it with Extract Class. 8
  • Look for objects that are only getters and setters, with all rules in a service. Fowler calls this an anemic domain model. He calls it "really just a procedural style design". 7 Move the rule next to the data it reads.
  • Do not chase getters everywhere, though. Fowler himself says, "personally, I don't use tell-dont-ask". He still puts data and behaviour together, but he has seen the rule push people to remove every getter. 6
  • When you see a new abstract base class, ask what behaviour the subclasses change. If none, suggest a field.
  • When you see a new interface, ask for the second implementation. If nobody can name it, wait. Hello Interview says: "Build what you need now, not what you might need later." 5
  • For every shared object, ask: "What if two requests call this at once?" Look for a read, a decision and a write as three separate lines.
Section 6 of 8

With AI

What to ask the agent

"Here is my parking lot spec and its out-of-scope list. Propose the classes, with one sentence of responsibility each. Do not add any design pattern I did not ask for."

"In this class design, find every place where code reads a value, decides, then writes it back in a separate step. For each, say what two threads could do to break it."

"List the classes in this diff that only have getters and setters. For each, name the service method that holds its rules."

What to check yourself

  • The agent did not turn every noun into a class or add subclasses that change no behaviour.
  • Every pattern it added solves a change you can name.
  • The concurrency fix makes the check and the action one atomic step. A synchronized method that only wraps the check is not a fix.
  • The code compiles and a test with two threads passes many times in a row.
Section 7 of 8

Check yourself

1. An LLD interviewer says "Design a parking lot." What should you do in the first few minutes?

Show answer

Ask questions until the prompt is a small spec, and say what is out of scope. Hello Interview's framework starts with about 5 minutes of requirements, where you make the prompt unambiguous and name what is out of scope.

2. Car, Motorcycle and Truck differ only in which spot size they need. How should you model them?

Show answer

One Vehicle type with a size field, because there is no different behaviour. Subclasses that add no behaviour are inheritance used as labels. A field holds the difference, and a new size is one enum value.

3. Two gates call enter() at the same moment. Both see spot 14 as free and both issue a ticket for it. What is the root problem?

Show answer

Checking "is it free?" and taking the spot happen as two separate steps. This is check-then-act. Another thread can change the state between the check and the action, so the two must happen as one atomic step.

4. The interviewer asks for different prices for cars and trucks. Which change fits best?

Show answer

Put the fee rule behind a small PricingPolicy interface that ParkingLot calls. Pricing is now a real change pressure, so it earns a seam. ParkingLot keeps one job, and a new price rule is a new class.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 11 sources and related lessons
  1. Hello Interview, “Low Level Design in a Hurry” (opens in a new tab)
    What a low-level design round tests, how it differs from system design, and the five things interviewers judge.
  2. Hello Interview, “Low Level Design Interview Delivery Framework” (opens in a new tab)
    Five steps with rough times, from requirements to extensibility, and the warning against forcing patterns.
  3. Hello Interview, “Parking Lot Low Level Design” (opens in a new tab)
    A sample scope for the parking lot, what is out of scope, and three follow-up questions. The full answer is behind a paywall.
  4. Hello Interview, “Correctness in Low Level Design” (opens in a new tab)
    The two-users-one-seat race, explained as a check and an action done in two separate steps.
  5. Hello Interview, “Design Principles” (opens in a new tab)
    Short principles for interviews, including building only what you need now.
  6. Martin Fowler, “Tell Dont Ask”, martinfowler.com (5 September 2013) (opens in a new tab)
    Telling an object what to do instead of asking for its data, and Fowler's own doubts about the rule.
  7. Martin Fowler, “Anemic Domain Model”, martinfowler.com (25 November 2003) (opens in a new tab)
    Objects that are "bags of getters and setters", with all logic in service classes, and why Fowler calls it an anti-pattern.
  8. Refactoring.Guru, “Large Class” (opens in a new tab)
    How classes grow too big over time, and the refactorings that split them.
  9. Bill Venners, “Design Principles from Design Patterns: A Conversation with Erich Gamma, Part III”, Artima Developer (6 June 2005) (opens in a new tab)
    Gamma on composition over inheritance, and why he calls inheritance brittle.
  10. Oracle, “ConcurrentHashMap (Java SE 21 & JDK 21)” (opens in a new tab)
    The thread-safe map, and the exact behaviour of remove and putIfAbsent.
  11. Oracle, “AtomicReference (Java SE 21 & JDK 21)” (opens in a new tab)
    compareAndSet, which sets a new value only if the current one is still the expected one.

Related: SOLID, coupling and cohesion · Design patterns that still matter · Complexity and deep modules · Locks, atomics and deadlocks · Big-tech interview loops · The system design method, worked on Ticketmaster · Testing strategy that scales

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper