Bird
0
0

In a system using Chain of Responsibility, how would you modify the pattern to handle priority requests first without breaking the chain?

hard📝 Trade-off Q9 of 15
LLD - Behavioral Design Patterns — Part 2
In a system using Chain of Responsibility, how would you modify the pattern to handle priority requests first without breaking the chain?
AInsert priority handlers at the start of the chain
BRemove the chain and handle all requests immediately
CBroadcast all requests to every handler simultaneously
DIgnore priority and process requests in arrival order only
Step-by-Step Solution
Solution:
  1. Step 1: Understand Chain of Responsibility order

    Requests are passed along handlers in sequence.
  2. Step 2: Prioritize by chain order

    Placing priority handlers at the start ensures they get requests first.
  3. Step 3: Maintain chain integrity

    This approach keeps the chain intact while prioritizing important requests.
  4. Final Answer:

    Insert priority handlers at the start of the chain -> Option A
  5. Quick Check:

    Priority handled by chain order = C [OK]
Quick Trick: Place priority handlers first in chain [OK]
Common Mistakes:
MISTAKES
  • Breaking chain to handle requests immediately
  • Broadcasting requests breaks chain pattern
  • Ignoring priority defeats purpose

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes