Case study · Advanced

Design BookMyShow

Browse shows, pick seats, and book them — where the whole difficulty is concurrency: two users must never book the same seat.

Asked atAmazonBookMyShowUberAtlassian
step 1 / 8
1/2Model the booking domain
runs onseats **lockscreates
Show
- movie
- time
Screen
- seats
Seat
- id
- status
BookingService
+ book(seats, user)
SeatLock
- ttl
- heldBy
+ lock(seats)
+ unlock()
Booking
- seats
- user
Model the booking domain
1class Show { Movie movie; Screen screen; Time time; }
2class Screen { List<Seat> seats; }
3 
4class BookingService {
5 SeatLock lock;
6 Booking book(List<Seat> seats, User user) { ... }
7}
State
Showmovie + screen + time

The static model first: a Show runs on a Screen which OWNS its Seats (composition). A BookingService creates Bookings.