Bird
Raised Fist0

What is a key trade-off when using the Singleton pattern for managing the ParkingLot instance in a multi-level parking system?

medium🪤 Complexity Trap Q13 of Q15
OOP & Design Patterns - Design a Parking Lot - LLD with OOP (Classes, Patterns, Extensibility)
What is a key trade-off when using the Singleton pattern for managing the ParkingLot instance in a multi-level parking system?
ASingleton pattern automatically handles persistence of ParkingLot state across system restarts
BSingleton ensures only one ParkingLot instance, which simplifies global access but limits scalability for multiple lots
CSingleton improves concurrency by allowing multiple threads to create instances simultaneously
DSingleton eliminates the need for synchronization in multi-threaded environments
Step-by-Step Solution
  1. Step 1: Understand Singleton purpose

    Singleton restricts instantiation to one object, providing a global point of access.
  2. Step 2: Identify trade-offs

    While simplifying access, it limits flexibility and scalability, especially if multiple parking lots or levels need independent management.
  3. Step 3: Address misconceptions

    Singleton does not inherently improve concurrency or persistence, nor does it remove synchronization needs.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    Singleton simplifies access but restricts scalability [OK]
Quick Trick: Singleton = one instance, good for global access but bad for scalability [OK]
Common Mistakes:
MISTAKES
  • Believing Singleton improves concurrency or persistence
  • Assuming Singleton removes synchronization requirements
Trap Explanation:
PITFALL
  • Options B, C, and D reflect common misunderstandings about Singleton's capabilities and limitations.
Interviewer Note:
CONTEXT
  • Tests candidate's grasp of design pattern trade-offs and when not to use Singleton
Master "Design a Parking Lot - LLD with OOP (Classes, Patterns, Extensibility)" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes