Bird
Raised Fist0

Which combination of behavioral patterns is best suited?

hard📝 Trade-off Q15 of Q15
LLD - Behavioral Design Patterns — Part 2
You are designing a notification system where users can subscribe to different event types, and the system should allow adding new event types without changing existing code. Which combination of behavioral patterns is best suited?
AChain of Responsibility for subscriptions and Command for event handling
BCommand for subscriptions and Chain of Responsibility for event handling
CObserver for subscriptions and Strategy for event handling
DStrategy for subscriptions and Observer for event handling
Step-by-Step Solution
Solution:
  1. Step 1: Identify the subscription mechanism

    Users subscribing to events fits the Observer pattern, which supports dynamic subscription and notification.
  2. Step 2: Identify flexible event handling

    Strategy pattern allows interchangeable algorithms for handling different event types without changing existing code.
  3. Step 3: Combine patterns for extensibility

    Using Observer for subscriptions and Strategy for event handling supports adding new event types easily and keeps code maintainable.
  4. Final Answer:

    Observer for subscriptions and Strategy for event handling -> Option C
  5. Quick Check:

    Subscribe = Observer, flexible handling = Strategy [OK]
Quick Trick: Subscribe = Observer, flexible handling = Strategy [OK]
Common Mistakes:
MISTAKES
  • Mixing Command with subscriptions
  • Using Chain of Responsibility for subscriptions
  • Confusing Strategy with Observer roles

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes