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

Grow the design

Start with the smallest system that works. Change it only when something breaks.

Grow it

Four steps, each forced by a sentence

StepForced byChangeCost
1. List and scanThe first requiremententer walks over the spaces500 looks on a full day
2. Queues by size"Smallest fitting" and speedSpotPoolA space must never be in two queues
3. One lock"Several gates"Check plate, claim, write: one blockGates wait for microseconds
4. Price and payment outside"Marketing has ideas", "cards are slow"Two interfaces; pop, charge, releaseA gap that must be argued
Stop at step 4. Levels with locks, signs and bookings are answers to questions nobody has asked yet.

What is inside the lock, and what is not

The class diagram is on the UML page of the solution. Practise drawing it in this order: lot, pool, ticket, pricing, payments.