Please note that the content of this book primarily consists of articles
available from Wikipedia or other free sources online. In computer
programming, the strategy pattern is a particular software design
pattern, whereby algorithms can be selected at runtime. Formally
speaking, the strategy pattern defines a family of algorithms,
encapsulates each one, and makes them interchangeable. Strategy lets the
algorithm vary independently from clients that use it. For instance, a
class that performs validation on incoming data may use a strategy
pattern to select a validation algorithm based on the type of data, the
source of the data, user choice, and/or other discriminating factors.
These factors are not known for each case until run-time, and may
require radically different validation to be performed. The validation
strategies, encapsulated separately from the validating object, may be
used by other validating objects in different areas of the system
without code duplication.