Bird
0
0

You want to design a system where a Hotel manages multiple Rooms and allows Bookings only if rooms are available. Which design approach best supports scalability and maintainability?

hard📝 Trade-off Q15 of 15
LLD - Design — Hotel Booking System
You want to design a system where a Hotel manages multiple Rooms and allows Bookings only if rooms are available. Which design approach best supports scalability and maintainability?
AMake Booking class manage all Rooms and Guests directly, without Hotel involvement.
BStore all booking data inside Room class only, without separate Booking class.
CHave Hotel class contain a list of Room objects, and Booking class references Room and Guest; Hotel checks availability before booking.
DUse a single class combining Hotel, Room, and Booking functionalities.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze class responsibilities

    Hotel should manage Rooms, Booking should link Rooms and Guests, keeping clear separation.
  2. Step 2: Evaluate design for scalability

    Have Hotel class contain a list of Room objects, and Booking class references Room and Guest; Hotel checks availability before booking. cleanly separates concerns, allowing Hotel to check availability and Booking to handle reservations, supporting easy maintenance and scaling.
  3. Final Answer:

    Hotel manages Rooms; Booking references Room and Guest; Hotel checks availability -> Option C
  4. Quick Check:

    Separation of concerns = Have Hotel class contain a list of Room objects, and Booking class references Room and Guest; Hotel checks availability before booking. [OK]
Quick Trick: Separate Hotel, Room, Booking roles for clean design [OK]
Common Mistakes:
  • Combining all logic in one class
  • Booking managing Rooms directly
  • Ignoring availability checks in Hotel

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes