Bird
0
0

In designing a notification system supporting email, SMS, and push notifications, how does applying the Strategy pattern improve the system?

hard📝 Trade-off Q8 of 15
LLD - Behavioral Design Patterns — Part 1
In designing a notification system supporting email, SMS, and push notifications, how does applying the Strategy pattern improve the system?
AIt allows adding new notification methods without modifying existing code
BIt forces all notifications to use the same sending algorithm
CIt tightly couples notification types with the client code
DIt eliminates the need for interfaces or abstract classes
Step-by-Step Solution
Solution:
  1. Step 1: Understand Strategy pattern role

    It encapsulates algorithms (notification methods) and makes them interchangeable.
  2. Step 2: Benefit in notification system

    New notification types can be added by implementing the Strategy interface without changing existing code.
  3. Final Answer:

    It allows adding new notification methods without modifying existing code -> Option A
  4. Quick Check:

    Supports extension without modification [OK]
Quick Trick: Strategy enables easy extension of algorithms [OK]
Common Mistakes:
MISTAKES
  • Assuming all notifications use one algorithm
  • Believing it couples types tightly
  • Thinking interfaces are unnecessary

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes