software-engineer-blog logoSoftware Engineer Blog

Question 17 · Track 6 · Design the objects, not the boxes

Design a parking lot

If you draw a load balancer, you answered a different question.

Design the objects, not the boxes. 4 clarifying questions to ask first, the answer in 4 moves, the follow-up that catches a memorised answer and 2 supporting topics to watch or read.

What it is really testing

Class boundaries, an extensible assignment rule, and state you can query without scanning.

Ask these first

Before a single box goes on the board. The answers change the design, which is the point of asking out loud.

The answer, in 4 moves

In this order. Each move earns the next one — say them out loud rather than drawing all four and narrating afterwards.

  1. 1Model Vehicle, Spot, Level and Ticket as classes with real boundaries.
  2. 2Make assignment a strategy object, so a new rule is a new class, not an if-chain.
  3. 3Keep per-level free counters instead of scanning spots to answer "is there room".
  4. 4Tie the ticket to entry and exit timestamps; the fee is a function of those.

The trap

The follow-up that separates a rehearsed answer from a real one.

This is an object-design question wearing a system-design coat. Reaching for queues and shards signals you cannot tell the two rounds apart — the interviewer wants to see where you put behaviour.

Watch or read

The pieces of this answer, each covered on its own. Take them whichever way suits you, then give the whole answer without looking.

Architecture patterns

Event-driven, layered, monolithic, microservices, MVC, primary-replica — teams compare these six as if they were alternatives, which is why the meeting never ends. They are not alternatives. They sit on three different levels: the deploy unit, the code organisation, and the data topology. Here is the sort, proved on a real 246-line FastAPI service where four of the six are true at the same moment, with the price of each level measured rather than argued.

ReelRead

Route handler vs service vs repository

The rule for publishing an article ends up in four files — the web handler, a nightly job, a CLI, a webhook — and one of them never gets the fix. This is the whole extraction, line by line: what belongs in the handler, what belongs in the...

ReelRead

Part of System Design Interviews, Answered Out Loud. The fundamentals underneath it are the free CS course.