Bird
0
0

Which design pattern best supports adding new piece movement behaviors at runtime without modifying existing classes?

hard📝 Trade-off Q9 of 15
LLD - Design — Chess Game
Which design pattern best supports adding new piece movement behaviors at runtime without modifying existing classes?
AFactory Method Pattern
BSingleton Pattern
CStrategy Pattern
DObserver Pattern
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirement

    Need to add new movement behaviors dynamically without changing existing code.
  2. Step 2: Evaluate patterns

    Strategy Pattern encapsulates algorithms (movement rules) and allows swapping at runtime.
  3. Step 3: Confirm best fit

    Strategy Pattern enables dynamic behavior changes without modifying piece classes.
  4. Final Answer:

    Strategy Pattern -> Option C
  5. Quick Check:

    Strategy pattern enables runtime behavior changes [OK]
Quick Trick: Strategy pattern enables dynamic behavior changes [OK]
Common Mistakes:
  • Confusing with Singleton which controls instance count
  • Factory Method creates objects but not behavior changes
  • Observer is for event notification, not behavior encapsulation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes