Bird
Raised Fist0

How should you design the classes to keep the system scalable and maintainable?

hard📝 Trade-off Q8 of Q15
LLD - Design — Hotel Booking System
You need to design a system with a room type hierarchy where some rooms have special features like projectors or whiteboards. How should you design the classes to keep the system scalable and maintainable?
AUse only one class for all rooms with many optional attributes
BCreate a base Room class with common attributes, then subclasses for each room type adding specific features
CCreate separate unrelated classes for each feature without inheritance
DPut all features in the base Room class and ignore subclasses
Step-by-Step Solution
Solution:
  1. Step 1: Identify scalable design principles

    Base class with common attributes avoids duplication; subclasses add specific features.
  2. Step 2: Evaluate options

    Putting all features in base or one class causes clutter; unrelated classes lose hierarchy benefits.
  3. Final Answer:

    Create a base Room class with common attributes, then subclasses for each room type adding specific features -> Option B
  4. Quick Check:

    Use base + subclasses for scalable design [OK]
Quick Trick: Base class for common, subclasses for specifics [OK]
Common Mistakes:
MISTAKES
  • Overloading base class with all features
  • Ignoring inheritance benefits
  • Using unrelated classes without hierarchy

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes