Bird
Raised Fist0

In a Strategy pattern implementation, the context always uses the same strategy instance and never switches strategies. What is the main issue?

medium📝 Analysis Q7 of Q15
LLD - Behavioral Design Patterns — Part 2
In a Strategy pattern implementation, the context always uses the same strategy instance and never switches strategies. What is the main issue?
AStrategies do not implement a common interface
BContext calls strategy methods incorrectly
CContext does not provide a method to change strategy
DStrategies are stateless
Step-by-Step Solution
Solution:
  1. Step 1: Identify strategy switching mechanism

    Strategy pattern requires context to switch strategies dynamically.
  2. Step 2: Check if context allows strategy change

    If context lacks method to change strategy, it will always use the same one.
  3. Final Answer:

    Context does not provide a method to change strategy -> Option C
  4. Quick Check:

    No strategy switch = Missing change method [OK]
Quick Trick: Allow context to switch strategies dynamically [OK]
Common Mistakes:
MISTAKES
  • Blaming strategy interface
  • Assuming incorrect method calls
  • Ignoring context responsibility

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes