23 Strategy

A STRATEGY IS A plan, or approach, for achieving an aim given certain input conditions. A strategy is thus similar to an algorithm, a procedure that produces an output from a set of inputs. Usually, there is more latitude in how a strategy pursues its goal than in an algorithm. This latitude also means that strategies often appear in groups, or families, of alternatives.

When multiple strategies appear in a computer program, the code may become complex. The logic that surrounds the strategies must select a strategy, and this selection code may itself become complex. The execution of various strategies may also lie along different code paths but in code that all resides in a single method. If the choice and execution of various ...

Get Design Patterns in Java™, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.