AlgoViz

Design a parking lot

medium 90 min

Model a car park with several levels as classes: vehicles, spaces of different sizes, tickets and a replaceable price rule.

Watch lesson4:48

Agree on the scope

Ask what changes the design, then commit to a short list.

Agree

The scope in one minute

Cutting it down

  1. You

    I would like to cover enter, leave, three sizes with fallback, a replaceable price, and several gates. Out for now: booking, passes, electric, signs that push. Payment is an interface. Does that match what you want to see?

  2. Interviewer

    Yes. What about a lost ticket?

  3. You

    I will keep plates as an index, because I need it anyway to refuse a car that is already inside. With that, a lost ticket is a lookup plus another price. I can show it at the end.

  4. Interviewer

    And what if I want buses to take five spaces?

  5. You

    That changes the claim and nothing else. I will keep the claim in one method, so that the change has one place.

What each answer decides

They sayYou write
"One gate"No lock, and say where it would go
"Small may not use large"No loop upwards: one queue
"Free for the first 15 minutes"A wrapper around the rule
"Cars pay at a machine inside"A status: active, paid, left
"Levels have their own signs"A listener, and level becomes a class
"It must survive a restart"Tickets are stored; free is rebuilt from them

Functional

  • Enter: smallest fitting free space, ticket
  • Leave: price, charge, release
  • Free counts by size
  • A plate is inside once
  • A ticket is used once

Not today

  • Booking and passes
  • Finding your car
  • Cameras
  • Reports
  • Several car parks