LOW-LEVEL DESIGN · THE LLD INTERVIEW · METHOD · 48 OF 48

Common Low-Level Design Interview Mistakes and How to Fix Them

The mistakes that sink most low-level design rounds, each with its fix: jumping straight to code, god classes, patterns used for show, ignoring concurrency, designs that cannot extend, unreadable names and primitive money, no demo or test, silent failures and over-engineering, shown as a before and after refactor of a small checkout in Java.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
1 / 16

Press play to hear the narration, or step through at your own pace. The Java example is below.

Java example

One file, Java 17, 208 lines, with a small main() demo. Save it as CheckoutRefactorDemo.java, then run javac CheckoutRefactorDemo.java && java CheckoutRefactorDemo.

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicLong;

/** Common LLD mistakes as a before/after refactor of a tiny checkout. */
public class CheckoutRefactorDemo {

    public static void main(String[] args) throws InterruptedException {
        // ---------- BEFORE: god class, cryptic names, double money, magic strings ----------
        OrdMgr old = new OrdMgr();
        System.out.println("Before, standard: " + old.calc("std", 59.97, 3));
        System.out.println("Before, typo 'express': " + old.calc("express", 59.97, 3) + " (free delivery!)");

        // ---------- AFTER: small classes, Money in paise, fee policies, thread-safe store ----------
        InMemoryOrderStore store = new InMemoryOrderStore();
        List<String> texts = new CopyOnWriteArrayList<>(); // listener may run on many threads
        OrderListener sms = order -> texts.add("SMS order " + order.id());
        CheckoutService checkout = new CheckoutService(store, sms, 10);

        Money items = Money.of(59, 97);
        PlacedOrder a = checkout.place(new OrderRequest("cust-1", items, 3, new StandardDelivery()));
        PlacedOrder b = checkout.place(new OrderRequest("cust-2", items, 3, new ExpressDelivery()));
        System.out.println("After, standard: " + a.total());
        System.out.println("After, express:  " + b.total());

        // ---------- Mistake 7 fixed: a main that checks the behaviour ----------
        check("standard fee for 3 km is Rs 45.00", new StandardDelivery().fee(3).equals(Money.of(45, 0)));
        check("express fee for 3 km is Rs 84.00", new ExpressDelivery().fee(3).equals(Money.of(84, 0)));
        check("10% off Rs 104.97 is Rs 94.47", a.total().equals(Money.of(94, 47)));
        check("listener told about both orders", texts.size() == 2);
        try {
            new OrderRequest("", Money.of(10, 0), 1, new StandardDelivery());
            check("blank customer rejected", false);
        } catch (IllegalArgumentException e) {
            check("blank customer rejected: " + e.getMessage(), true);
        }

        // Concurrency: 100 orders from 4 threads, every id unique
        CountDownLatch go = new CountDownLatch(1);
        List<Thread> threads = new ArrayList<>();
        for (int t = 0; t < 4; t++) {
            Thread th = new Thread(() -> {
                try {
                    go.await();
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    return;
                }
                for (int i = 0; i < 25; i++) {
                    checkout.place(new OrderRequest("cust-bulk", Money.of(10, 0), 1, new StandardDelivery()));
                }
            });
            threads.add(th);
            th.start();
        }
        go.countDown();
        for (Thread th : threads) {
            th.join();
        }
        check("102 orders stored with unique ids", store.count() == 102 && store.ids().size() == 102);
    }

    static void check(String name, boolean ok) {
        System.out.println((ok ? "PASS " : "FAIL ") + name);
    }
}

// =================== BEFORE ===================
/** Prices, discounts, saves and "texts" in one method. Strings for types, double for money. */
class OrdMgr {
    static List<String> lst = new ArrayList<>(); // shared by every request, not thread safe

    double calc(String t, double amt, int km) {
        double f;
        if (t.equals("std")) {
            f = 30 + km * 5;
        } else if (t.equals("exp")) {
            f = 60 + km * 8;
        } else {
            f = 0; // unknown type: silently free
        }
        double tot = amt + f;
        tot = tot - tot * 0.1; // hard-coded discount, floating point money
        lst.add(t + ":" + tot);
        System.out.println("  SMS: order placed, total " + tot); // side effect hidden in a calculation
        return tot;
    }
}

// =================== AFTER ===================
/** Money as whole paise: no rounding drift. */
record Money(long paise) {
    Money {
        if (paise < 0) {
            throw new IllegalArgumentException("money cannot be negative");
        }
    }

    static Money of(long rupees, int paise) {
        return new Money(rupees * 100 + paise);
    }

    static Money rupees(long rupees) {
        return new Money(rupees * 100);
    }

    Money plus(Money other) {
        return new Money(paise + other.paise);
    }

    Money percentOff(int percent) {
        return new Money((paise * (100 - percent) + 50) / 100); // round half up to whole paise
    }

    @Override
    public String toString() {
        return String.format("Rs %d.%02d", paise / 100, paise % 100);
    }
}

/** Mistake 5 fixed: a new delivery type is a new class, and a typo does not compile. */
interface DeliveryFeePolicy {
    Money fee(int km);
}

final class StandardDelivery implements DeliveryFeePolicy {
    @Override
    public Money fee(int km) {
        return Money.rupees(30).plus(Money.rupees(5L * km));
    }
}

final class ExpressDelivery implements DeliveryFeePolicy {
    @Override
    public Money fee(int km) {
        return Money.rupees(60).plus(Money.rupees(8L * km));
    }
}

/** Mistake 8 fixed: bad input fails loudly where it enters. */
record OrderRequest(String customer, Money itemsTotal, int km, DeliveryFeePolicy delivery) {
    OrderRequest {
        if (customer == null || customer.isBlank()) {
            throw new IllegalArgumentException("customer is required");
        }
        if (km < 0) {
            throw new IllegalArgumentException("distance cannot be negative");
        }
    }
}

record PlacedOrder(long id, String customer, Money total) { }

interface OrderStore {
    PlacedOrder save(String customer, Money total);
}

/** Mistake 4 fixed: thread-safe map and atomic ids instead of a static ArrayList. */
final class InMemoryOrderStore implements OrderStore {
    private final Map<Long, PlacedOrder> orders = new ConcurrentHashMap<>();
    private final AtomicLong nextId = new AtomicLong(1);

    @Override
    public PlacedOrder save(String customer, Money total) {
        PlacedOrder order = new PlacedOrder(nextId.getAndIncrement(), customer, total);
        orders.put(order.id(), order);
        return order;
    }

    int count() {
        return orders.size();
    }

    Set<Long> ids() {
        return Set.copyOf(orders.keySet());
    }
}

interface OrderListener {
    void placed(PlacedOrder order);
}

/** Mistake 2 fixed: the service only coordinates. Each job lives in its own type. */
final class CheckoutService {
    private final OrderStore store;
    private final OrderListener listener;
    private final int discountPercent;

    CheckoutService(OrderStore store, OrderListener listener, int discountPercent) {
        this.store = store;
        this.listener = listener;
        this.discountPercent = discountPercent;
    }

    PlacedOrder place(OrderRequest request) {
        Money total = request.itemsTotal()
                .plus(request.delivery().fee(request.km()))
                .percentOff(discountPercent);
        PlacedOrder order = store.save(request.customer(), total);
        listener.placed(order);
        return order;
    }
}

Notes

The list

Here is the list. Jumping straight to code. One god class. Patterns used for show. Ignoring concurrency. A design with no room to extend. Cryptic names and money stored as a double. No demo or test. Silent failures and null returns. And the opposite trap, over-engineering. We will take them one at a time, each with a concrete fix.

Mistakes to avoid
  • 1 jumping straight to code
  • 2 one god class
  • 3 patterns for show
  • 4 ignoring concurrency
  • 5 no room to extend
  • 6 cryptic names, double money
  • 7 no demo or test
  • 8 silent failures, nulls
  • 9 over-engineering

1 · Jumping to code

Mistake one is opening the editor in minute two. You end up designing in your head, alone and in silence, and you often build the wrong thing. The fix is the method from the last lesson: five minutes on requirements and scope, then entities, a quick diagram and the main flows, and only then code. A wrong assumption found at minute four costs one sentence. Found at minute forty, it costs the round.

Fix: design first
  • minutes 0-5: requirements
  • and scope, out loud
  • minutes 5-20: entities,
  • diagram, flows
  • then code, with agreement
  • a wrong guess found at
  • minute 4 costs a sentence;
  • at minute 40 it costs
  • the round

2 · God class

Here is the before code, a class called OrdMgr. One method works out the delivery fee, applies a discount, saves the order into a static list and sends a text message. It has four reasons to change, so every change risks breaking the other three. You cannot test the price without also sending a message. This is a god class, and interviewers spot it in seconds.

Before: OrdMgr
double calc(String t, double amt, int km) {
  double f;
  if (t.equals("std")) f = 30 + km * 5;
  else if (t.equals("exp")) f = 60 + km * 8;
  else f = 0;
  double tot = amt + f;
  tot = tot - tot * 0.1;
  lst.add(t + ":" + tot);
  System.out.println("SMS: " + tot);
  return tot;
}

2 · Fix: split it

The fix is to give each job its own home. A DeliveryFeePolicy works out fees. Money handles amounts and discounts. An OrderStore saves orders. An OrderListener reacts when an order is placed, for example by sending a text. CheckoutService just coordinates them in the right order. Each class now has one reason to change, and each can be tested or replaced alone.

3 · Patterns for show

Mistake three is naming patterns to impress. A factory, a builder and a singleton, before any need exists. Interviewers read this as memorised, not designed. Flip the order: start from a pain, then name the pattern that removes it. Fees change by city and delivery speed, so the fee is a Strategy. A simple test: can you finish the sentence, I used this because, with a real requirement?

Fix: pain first
  • bad: "I will add a Factory,
  • a Builder and a Singleton"
  • good: "fees change by city,
  • so the fee is a Strategy"
  • test: can you finish
  • "I used X because ..."
  • with a real requirement?

4 · Ignoring concurrency

Mistake four is ignoring threads. The old class adds to a static array list shared by every request. Two checkouts at once can corrupt it or lose an order, and ids can repeat. The fix: name the shared state and protect it. Orders go into a ConcurrentHashMap, ids come from an AtomicLong, and data passed between classes is an immutable record. Bring this up before the interviewer asks; it is one of the strongest signals you can give.

Fix: name the shared state
  • before: static List lst =
  • new ArrayList() // shared
  • after:
  • • ConcurrentHashMap for orders
  • • AtomicLong for order ids
  • • immutable records passed
  • between classes
  • say it before they ask

5 · No room to extend

Mistake five is a design that cannot grow. In the old code, a new delivery type means another else if inside the god method, and a typo like express instead of exp silently makes delivery free. The fix: put the varying rule behind an interface. Standard and express are classes implementing DeliveryFeePolicy. Adding scheduled delivery is a new class, and a misspelt type no longer compiles.

Fix: an interface
interface DeliveryFeePolicy {
  Money fee(int km);
}
final class ExpressDelivery
    implements DeliveryFeePolicy {
  public Money fee(int km) {
    return Money.rupees(60)
        .plus(Money.rupees(8 * km));
  }
}

6 · Names and types

Mistake six is names nobody can read and the wrong types. OrdMgr, calc, t, f, lst and tot force the interviewer to decode your code. Use full words: CheckoutService, place, delivery, fee. Money as a double gives rounding errors, so wrap it in a Money record holding whole paise in a long. Replace magic strings with enums or real types. Good names are free, and they make your design easy to follow.

Fix: say what you mean
  • OrdMgr, calc, t, f, lst, tot
  • -> CheckoutService, place,
  • delivery, fee, orders,
  • total
  • double money -> Money record
  • in long paise
  • "std" / "exp" -> types the
  • compiler checks

7 · No demo or test

Mistake seven is never running the code. If you stop at the last class, the interviewer has to trust that it works. The fix costs five minutes: a main method with a few named checks that print pass or fail. Check the fee for each delivery type, the discount, an edge case, and one concurrent run. Bugs you catch yourself count in your favour, and bugs they catch count against you.

Fix: prove it
static void check(String name,
                  boolean ok) {
  System.out.println(
      (ok ? "PASS " : "FAIL ") + name);
}

check("express fee", ...);
check("10% discount", ...);
check("100 parallel orders", ...);

8 · Silent failures

Mistake eight is failing silently. The old code treats an unknown delivery type as free, and lookups return null that crashes three calls later. The fix is to fail loudly and early. Validate input where it enters, use Optional when something may not exist, and throw exceptions with a message that says what went wrong. A clear error is part of a good design, not an afterthought.

Fix: fail loudly
  • before: unknown type ->
  • fee 0, nobody notices
  • before: return null when
  • not found
  • after:
  • • validate input at the edge
  • • Optional for "not found"
  • • exceptions with a message
  • that says what to fix

9 · Over-engineering

Mistake nine is the opposite of the god class: too many layers. Interfaces with one implementation and no likely second one, factories that build factories, a generic framework for a forty five minute problem. You run out of time and the design becomes hard to explain. Add seams only where change is likely, like fees and notifications, and keep the rest plain and direct.

Fix: just enough
  • signs:
  • • an interface with one
  • implementation and no
  • likely second one
  • • factories of factories
  • • generic frameworks for
  • a 45-minute problem
  • add seams where change is
  • likely; keep the rest plain

After: the flow

Here is the refactored flow for one order. The checkout service asks the delivery policy for the fee for three kilometres: forty five rupees. Money adds it to the item total and takes ten percent off, rounding to whole paise. The store saves the order with a fresh id, and the listener is told the order was placed, which is where the text message goes. Each step lives in the class that owns it.

After: the code

And the after code. The place method reads almost like the requirement: total equals the items plus the delivery fee, minus the discount. Save it, tell the listener, return the order. No string checks, no doubles, no shared array list, no hidden text messages. The class is short enough to explain in thirty seconds, which is exactly what you want in an interview.

CheckoutService.place()
PlacedOrder place(OrderRequest r) {
  Money total = r.itemsTotal()
      .plus(r.delivery().fee(r.km()))
      .percentOff(discountPercent);
  PlacedOrder order = store.save(
      r.customer(), total);
  listener.placed(order);
  return order;
}

A last-5-minutes check

Before you say you are done, run a quick self review. Are the requirements written down? Does any class do three or more jobs? Does every pattern have a reason? Is shared state protected? Is a new type just a new class? Are the names readable and money safe? Does main run? Are errors visible? Fixing even one item in the last five minutes, out loud, shows the self awareness interviewers look for.

Self-review
  • □ requirements written down?
  • □ any class doing 3+ jobs?
  • □ each pattern has a reason?
  • □ shared state protected?
  • □ new type = new class?
  • □ names readable, money safe?
  • □ main runs and prints?
  • □ errors are visible?

Interview questions

What is the most common mistake in LLD interviews?

Jumping into code without agreeing on requirements and a design. Candidates build the wrong thing or run out of time. Spending the first 15 to 20 minutes on scope, entities, a diagram and flows avoids most later trouble.

What is a god class and how do you fix it?

A class that does many unrelated jobs, such as pricing, saving and notifying. It is hard to change and test. Split it so each class has one reason to change, and keep a thin service that coordinates them.

How many design patterns should an LLD answer use?

As many as there are real problems to solve, usually two or three. Each should be justified by a requirement, such as a Strategy for fees that vary. Patterns added for show are a negative signal.

Why should money not be stored as a double?

Binary floating point cannot represent most decimal fractions exactly, so sums and discounts drift by tiny amounts and comparisons fail. Use a long count of the smallest unit, such as paise or cents, or BigDecimal with an explicit rounding rule.

How do you show your design is extensible?

Put the parts likely to change behind interfaces and show that a new requirement is a new class or enum value, not edits across existing code. Then answer what-if questions by pointing at the exact seam.

Should I write tests in an LLD interview?

At least a demo main that runs the main flow and a few edge cases, ideally printing pass or fail. It proves the code works, catches your own bugs early and shows a habit of verifying work.

Can a design be too flexible?

Yes. Interfaces with only one plausible implementation, layered factories and generic frameworks waste time and make the design hard to explain. Add abstraction where change is likely and keep everything else simple.

How should errors be handled in LLD code?

Validate input at the boundary, return Optional when a value may be absent, and throw exceptions with clear messages for invalid states. Avoid silent defaults such as a zero fee for an unknown type and avoid returning null.