Low level design, for machine coding and object oriented design rounds

Study Low-Level Design.

Design principles, patterns and full designs, written the way the interview wants them, in Java that compiles and runs.

Start with Single Responsibility PrincipleSee all articles

Free to read, no signup required.

Two changes to a checkout built with the Strategy pattern, side by side. Adding a shipping option touches one new class. Adding a new question touches the interface and every option class.

Every decision here is argued with the code it changes.

SOLID Principles

5

Five rules for classes that are easy to change, each shown on code that breaks it and code that follows it.

  1. 01Single Responsibility Principle
    • 9 min read
  2. 02Open/Closed Principle
    • 9 min read
  3. 03Liskov Substitution Principle
    • 9 min read
  4. 04Interface Segregation Principle
    • 9 min read
  5. 05Dependency Inversion Principle
    • 11 min read

Design Principles

7

Everyday rules of thumb for classes that are easy to read, test and change.

  1. 01Encapsulation
    • 6 min read
  2. 02Composition over inheritance
    • 7 min read
  3. 03Coupling and cohesion
    • 7 min read
  4. 04Program to an interface, not an implementation
    • 6 min read
  5. 05DRY, KISS and YAGNI
    • 6 min read
  6. 06Law of Demeter
    • 6 min read
  7. 07Immutability
    • 7 min read

Creational Patterns

5

Ways to create objects without tying the caller to one class or to a long constructor.

  1. 01Factory patternAppears inRate Limiter
    • 25 min read
  2. 02Builder pattern
    • 26 min read
  3. 03Singleton pattern
    • 22 min read
  4. 04Prototype pattern
    • 23 min read
  5. 05Object Pool pattern
    • 22 min read

Structural Patterns

7

Ways to fit classes together: wrap one, stand in for one, or put a simple front on many.

  1. 01Adapter pattern
    • 28 min read
  2. 02Decorator patternAppears inBookMyShowLogging FrameworkHotel Booking
    • 24 min read
  3. 03Facade pattern
    • 24 min read
  4. 04Composite pattern
    • 25 min read
  5. 05Proxy pattern
    • 24 min read
  6. 06Bridge pattern
    • 20 min read
  7. 07Flyweight pattern
    • 23 min read

Behavioral Patterns

13

Ways to split up behaviour: who decides, who gets told, and who does the work.

  1. 01Strategy patternAppears inParking LotElevator SystemSplitwise+22
    • 23 min read
  2. 02Observer patternAppears inParking LotLRU CacheLogging Framework+2
    • 22 min read
  3. 03State patternAppears inVending Machine
    • 23 min read
  4. 04Command pattern
    • 27 min read
  5. 05Template Method pattern
    • 23 min read
  6. 06Chain of Responsibility pattern
    • 25 min read
  7. 07Iterator pattern
    • 24 min read
  8. 08Mediator patternAppears inElevator System
    • 24 min read
  9. 09Memento pattern
    • 24 min read
  10. 10Visitor pattern
    • 24 min read
  11. 11Interpreter pattern
    • 23 min read
  12. 12Null Object patternAppears inFood Delivery (DoorDash, Swiggy)
    • 21 min read
  13. 13Specification pattern
    • 22 min read

Concurrency Patterns

4

Ways to share work and data between threads: who makes it, who does it, how many run at once, and who may read or write.

  1. 01Producer-Consumer patternAppears inPub-Sub
    • 19 min read
  2. 02Thread Pool pattern
    • 24 min read
  3. 03Bounded Blocking Queue pattern
    • 23 min read
  4. 04Read-Write Lock pattern
    • 25 min read

Full Designs

27

One interview question, designed end to end the way a 45 minute low-level design round goes.

  1. 01Parking LotUsesStrategy patternObserver pattern
    • 30 min read
  2. 02Elevator SystemUsesStrategy patternMediator pattern
    • 30 min read
  3. 03SplitwiseUsesStrategy pattern
    • 30 min read
  4. 04BookMyShowUsesStrategy patternDecorator pattern
    • 30 min read
  5. 05ATMUsesStrategy pattern
    • 33 min read
  6. 06Tic-Tac-ToeUsesStrategy pattern
    • 28 min read
  7. 07LRU CacheUsesStrategy patternObserver pattern
    • 29 min read
  8. 08Library Management SystemUsesStrategy pattern
    • 32 min read
  9. 09Snake and LadderUsesStrategy pattern
    • 29 min read
  10. 10Rate LimiterUsesStrategy patternFactory pattern
    • 27 min read
  11. 11Meeting Room SchedulerUsesStrategy pattern
    • 31 min read
  12. 12Logging FrameworkUsesStrategy patternDecorator patternObserver pattern
    • 31 min read
  13. 13ChessUsesStrategy pattern
    • 28 min read
  14. 14Ride Sharing (Uber)UsesStrategy pattern
    • 25 min read
  15. 15Hotel BookingUsesStrategy patternDecorator pattern
    • 27 min read
  16. 16Food Delivery (DoorDash, Swiggy)UsesStrategy patternNull Object pattern
    • 28 min read
  17. 17Stack OverflowUsesStrategy pattern
    • 24 min read
  18. 18Vending MachineUsesState pattern
    • 30 min read
  19. 19Car RentalUsesStrategy pattern
    • 27 min read
  20. 20Pub-SubUsesStrategy patternProducer-Consumer pattern
    • 29 min read
  21. 21Notification ServiceUsesStrategy pattern
    • 24 min read
  22. 22Shopping Cart (Amazon, Flipkart)UsesStrategy pattern
    • 27 min read
  23. 23Traffic Signal
    • 26 min read
  24. 24Online AuctionUsesStrategy patternObserver pattern
    • 24 min read
  25. 25Inventory ManagementUsesStrategy patternObserver pattern
    • 29 min read
  26. 26URL ShortenerUsesStrategy pattern
    • 26 min read
  27. 27Ticket WaitlistUsesStrategy pattern
    • 24 min read

More coming soon.

Article

Send feedback

Thank you for helping. We read every report and fix what is wrong.

How do you feel about oneby7?

Sign in to oneby7

Keep your progress, your streak and your code, on any device.

New here? This creates your account too.