Skip to content
Preptima
hardCodingDesignMidSenior

Design a movie ticket booking system with shows, seats and a temporary hold that expires if the user does not pay. Write the classes.

A ticket booking design models a Show that owns its seat states and a Hold with an owner, seat set and expiry. Holds are taken all-or-nothing under a per-show lock, expiry is checked lazily so no timer decides correctness, and starting payment moves the hold to a state the timer can no longer release.

6 min readUpdated 2026-10-10

Answer

Short answer

Treat the hold as a first-class object. A movie ticket booking system models a Show that owns the state of its seats and a Hold with an owner, a set of seats, an expiry and its own lifecycle. A seat hold is taken all-or-nothing under the show's lock, a seat counts as free if its hold has expired even before anything cleans it up, and starting payment moves the hold into a state that expiry no longer touches. Confirm turns held seats into booked seats; release or expiry makes them available again.

Was this answer helpful?

Likely follow-ups

  • The user double-clicks Hold and two identical requests arrive. What does your second call return?
  • How would you cap each user at ten held seats per show without a second lock?
  • The payment callback never arrives. Which component notices, after how long, and what does it do to the seats?
  • Theatres want to block a row for wheelchair access for some shows only. Where does that rule live?

Related questions