DSA Factory
Free Low-level design lessonsLow-level design · Stage 1 · Case studies · Step 2

Case study: parking lot

Entities, spot allocation and fee calculation, and where strategy and factory earn their place. About 14 minutes.

Quick check

Which parts of a parking lot design are the best candidates for the strategy pattern?

  1. AChoosing a spot and computing the fee, since both rules change
  2. BStoring the licence plate
  3. CCounting floors
Show the answer

Choosing a spot and computing the fee, since both rules change. Each can be swapped without touching ParkingLot.

Lock it in

4 questions on this idea

Short questions that apply the idea to new cases: trace it, work out a number, put steps in order. A wrong answer explains itself.

Answer them in your browserFree account, no card. Your progress is saved, and the idea comes back in a quick review later.
Sign up free to solve