Bird
Raised Fist0

Why is it important to avoid tight coupling between the subject and observers in a notification system?

hard🧠 Conceptual Q10 of Q15
LLD - Design — Online Shopping Cart
Why is it important to avoid tight coupling between the subject and observers in a notification system?
ATo force all observers to implement the same interface.
BTo make the subject dependent on specific observer implementations.
CTo ensure observers cannot receive notifications.
DTo allow observers to be added or removed without changing the subject code.
Step-by-Step Solution
Solution:
  1. Step 1: Understand coupling in design

    Tight coupling means components depend heavily on each other, making changes difficult.
  2. Step 2: Benefits of loose coupling in notifications

    Loose coupling allows adding/removing observers freely without modifying the subject, improving flexibility.
  3. Final Answer:

    To allow observers to be added or removed without changing the subject code. -> Option D
  4. Quick Check:

    Loose coupling = flexible observer management [OK]
Quick Trick: Loose coupling enables flexible observer changes [OK]
Common Mistakes:
MISTAKES
  • Thinking tight coupling is beneficial
  • Believing subject should depend on observers
  • Assuming observers cannot receive notifications

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes