Bird
Raised Fist0

If the parking lot system must support real-time spot availability updates and notifications to multiple display boards and mobile apps, which design pattern should be introduced to decouple the parking lot state changes from the notification logic?

hard🎤 Interviewer Follow-up Q10 of Q15
OOP & Design Patterns - Design a Parking Lot - LLD with OOP (Classes, Patterns, Extensibility)
If the parking lot system must support real-time spot availability updates and notifications to multiple display boards and mobile apps, which design pattern should be introduced to decouple the parking lot state changes from the notification logic?
ASingleton pattern to centralize notification management
BObserver pattern to notify subscribers on state changes
CFactory pattern to create notification objects
DStrategy pattern to select notification channels dynamically
Step-by-Step Solution
Solution:
  1. Step 1: Identify need for decoupling state changes and notifications

    Parking lot state changes must trigger updates without tight coupling.
  2. Step 2: Analyze pattern roles

    Observer pattern allows multiple subscribers to be notified on changes; Singleton centralizes instances but doesn't handle notifications; Factory creates objects but not notification flow; Strategy selects algorithms but not event propagation.
  3. Step 3: Select appropriate pattern

    Observer pattern fits perfectly for event-driven notifications.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    Observer decouples event source and listeners [OK]
Quick Trick: Observer pattern decouples event and notification [OK]
Common Mistakes:
MISTAKES
  • Choosing Singleton for notification management
  • Confusing Factory with event handling
  • Using Strategy for event propagation
Trap Explanation:
PITFALL
  • Candidates confuse object creation or instance control with event notification responsibilities.
Interviewer Note:
CONTEXT
  • Assesses knowledge of behavioral patterns for event-driven design.
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