Design a parking lot
medium 90 minModel 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
| Step | Forced by | Change | Cost |
|---|---|---|---|
| 1. List and scan | The first requirement | enter walks over the spaces | 500 looks on a full day |
| 2. Queues by size | "Smallest fitting" and speed | SpotPool | A space must never be in two queues |
| 3. One lock | "Several gates" | Check plate, claim, write: one block | Gates wait for microseconds |
| 4. Price and payment outside | "Marketing has ideas", "cards are slow" | Two interfaces; pop, charge, release | A gap that must be argued |
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.