Multiple choice technology architecture

Key Concept for applying the Strategy Pattern:

  1. At any given time only one algorithm is instantiated and active

  2. The Strategy pattern encapsulates related classes that have different functionalities

  3. The name of the message to the strategy object and the context object must be the same

  4. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. The context object delegates work to a strategy object, and at runtime, only one strategy instance is active and being used. This allows the algorithm to vary independently from clients that use it. Option A correctly identifies that only one strategy is active at a time, the selected strategy. Option B incorrectly suggests the pattern encapsulates classes with different functionalities (it encapsulates interchangeable algorithms for the same task). Option C incorrectly imposes a naming constraint that isn't part of the pattern. Option D is incorrect since option A is valid.