Bird
Raised Fist0

Why is it better to have the ParkingLot class manage multiple Floor objects instead of managing Spot objects directly?

hard🧠 Conceptual Q10 of Q15
LLD - Design — Parking Lot System
Why is it better to have the ParkingLot class manage multiple Floor objects instead of managing Spot objects directly?
AIt improves scalability and organizes spots by floors
BIt reduces the number of classes needed
CIt allows vehicles to park without spots
DIt makes Floor class unnecessary
Step-by-Step Solution
Solution:
  1. Step 1: Understand hierarchical organization

    Parking lots have floors, and floors have spots, so organizing by floors is natural.
  2. Step 2: Benefits of managing floors

    Managing floors improves scalability and simplifies spot management grouped by floor.
  3. Final Answer:

    It improves scalability and organizes spots by floors -> Option A
  4. Quick Check:

    Hierarchy improves scalability = D [OK]
Quick Trick: Use hierarchy: ParkingLot -> Floors -> Spots for scalability [OK]
Common Mistakes:
MISTAKES
  • Thinking fewer classes is always better
  • Ignoring natural hierarchy of parking structure
  • Assuming vehicles park without spots

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes