Bird
0
0

You are designing a parking lot system that must handle cars, bikes, and trucks with different spot sizes. Which design approach best supports scalability and maintainability?

hard📝 Trade-off Q15 of 15
LLD - Design — Parking Lot System
You are designing a parking lot system that must handle cars, bikes, and trucks with different spot sizes. Which design approach best supports scalability and maintainability?
ACreate separate classes for each vehicle and spot type with a common interface for parking logic
BUse a single class for all vehicles and spots with many if-else checks for types
CStore all vehicles in a single list and assign spots randomly
DDesign only for cars first, then add bikes and trucks later without changing code
Step-by-Step Solution
Solution:
  1. Step 1: Consider object-oriented design principles

    Using separate classes with a common interface allows clear modeling of different vehicle and spot types and their behaviors.
  2. Step 2: Evaluate scalability and maintainability

    This approach supports adding new vehicle types easily and keeps code clean, unlike monolithic classes or random assignments.
  3. Final Answer:

    Create separate classes for each vehicle and spot type with a common interface for parking logic -> Option A
  4. Quick Check:

    Use OOP with interfaces for scalable parking lot design [OK]
Quick Trick: Use separate classes and interfaces for each type [OK]
Common Mistakes:
MISTAKES
  • Using one class with many conditions
  • Ignoring scalability needs
  • Delaying design for other vehicle types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes