Low-Level Design

Object-oriented design for interviews: principles, all 23 classic design patterns in Java, concurrency, schema design, and 22 machine-coding case studies with runnable, tested Java solutions.

What you will learn

  • Turn a vague problem into entities, relationships and clean interfaces
  • Apply SOLID and the core design principles with judgment, not dogma
  • Recognise when each design pattern fits — and when it is over-engineering
  • Write thread-safe, extensible, testable Java under interview time pressure
  • Solve the most-asked machine-coding problems end to end

Foundations

How LLD rounds work, and the object-oriented building blocks every design rests on.

Design Principles

The principles that patterns are built on. Interviewers probe these directly.

  • SOLID Principles: Five principles with violations, fixes and the trade-offs of over-applying them.
  • Core Design Principles: Encapsulate what varies, program to interfaces, composition over inheritance, DRY, KISS, YAGNI and more.

Creational Patterns

Controlling how objects are created so that code does not depend on concrete classes.

  • Singleton: One instance, thread-safe initialisation, and why it is often an anti-pattern.
  • Factory Method & Abstract Factory: Decoupling creation from use: simple factory, factory method and families of products.
  • Builder: Constructing complex, valid, immutable objects step by step.
  • Prototype: Creating objects by cloning, deep vs shallow copies and prototype registries.

Structural Patterns

Assembling objects into larger structures while keeping them flexible.

  • Adapter: Making incompatible interfaces work together — object vs class adapters.
  • Decorator: Adding behaviour by wrapping, without subclass explosions.
  • Facade: A simple front door to a complex subsystem.
  • Proxy: Controlling access: lazy, protection, remote, caching and logging proxies.
  • Composite: Treating trees of objects and single objects uniformly.
  • Bridge: Splitting two dimensions of variation into independent hierarchies.
  • Flyweight: Sharing intrinsic state to support huge numbers of small objects.

Behavioral Patterns

How objects collaborate and divide responsibilities. The most-used group in LLD interviews.

  • Strategy: Interchangeable algorithms behind one interface.
  • Observer: Publish–subscribe inside a process, and its pitfalls.
  • State: Behaviour that changes with internal state — the backbone of many machine-coding problems.
  • Command: Requests as objects: queues, undo/redo, macros and audit logs.
  • Chain of Responsibility: Passing a request along a chain of handlers.
  • Template Method: A fixed algorithm skeleton with overridable steps.
  • Iterator: Traversing collections without exposing their internals.
  • Mediator: Replacing a web of object-to-object calls with a hub.
  • Memento: Snapshots for undo without breaking encapsulation.
  • Visitor: Adding operations to a stable class hierarchy via double dispatch.

Concurrency & Code Craft

What separates working code from interview-grade code: thread safety, errors, testability.

  • Concurrency for LLD: Race conditions, locks, atomics, concurrent collections and producer–consumer in Java.
  • Writing Interview-Grade Code: Modelling, validation, exceptions, immutability, testability and common anti-patterns.
  • Code Smells & Refactoring: Recognising smells and removing them with small, safe, named refactorings — with a verified worked example.
  • Schema Design for LLD: Mapping classes to tables, invariants as constraints, indexes from queries, and concurrency in SQL.

Case Studies: Core

The most frequently asked machine-coding problems, designed and implemented step by step.

Case Studies: Advanced

Harder problems that combine several patterns with real concurrency and business rules.

Case Studies: Business Systems

Product-company favourites where business rules, money and concurrency meet.

Revision

Consolidate patterns and principles before an interview.

Low-Level Design cheat sheet