Bird
Raised Fist0

Consider this scenario: You have a request that can be handled by multiple objects in a chain. Each object decides if it can handle the request or passes it on. Which pattern fits this design?

medium📝 Analysis Q13 of Q15
LLD - Behavioral Design Patterns — Part 2
Consider this scenario: You have a request that can be handled by multiple objects in a chain. Each object decides if it can handle the request or passes it on. Which pattern fits this design?
Request -> Handler1 -> Handler2 -> Handler3
ACommand pattern
BStrategy pattern
CObserver pattern
DChain of Responsibility pattern
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the request handling flow

    The request passes through a chain of handlers, each deciding to handle or forward it.
  2. Step 2: Identify the matching behavioral pattern

    The Chain of Responsibility pattern allows multiple objects to handle a request in sequence until one handles it.
  3. Final Answer:

    Chain of Responsibility pattern -> Option D
  4. Quick Check:

    Request passes chain = Chain of Responsibility [OK]
Quick Trick: Request passes chain? Use Chain of Responsibility [OK]
Common Mistakes:
MISTAKES
  • Confusing Chain with Command
  • Using Observer for request handling
  • Choosing Strategy incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes