Chapter 23. Strategy

A strategy is a plan, or approach, for achieving an aim, given certain input conditions. A strategy is similar to an algorithm: An algorithm is a well-defined procedure that produces an output from a set of inputs. A strategy is a plan that pursues an output given a set of inputs. Usually, however, a strategy has more latitude in how to pursue its goal than an algorithm does. This latitude also means that strategies often appear in groups, or families, of alternatives. When multiple strategies are available, the logic that surrounds the strategies must select one and then execute it. Complexity in the selection and use of strategies can lead to complex and tangled code. You can clean up such code with the STRATEGY pattern. ...

Get Design Patterns Java™ Workbook 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.