0% found this document useful (0 votes)
13 views1 page

Computer Programming Software Design Pattern Algorithm

The strategy pattern is a software design pattern that allows an algorithm's behavior to be selected at runtime. It defines a family of algorithms, encapsulates each algorithm, and makes the algorithms interchangeable. The strategy pattern lets the algorithm vary independently from clients that use it. For instance, a class that performs validation on data may use different validation algorithms or strategies based on factors like the data type or source that are not known until runtime.

Uploaded by

Rakesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Computer Programming Software Design Pattern Algorithm

The strategy pattern is a software design pattern that allows an algorithm's behavior to be selected at runtime. It defines a family of algorithms, encapsulates each algorithm, and makes the algorithms interchangeable. The strategy pattern lets the algorithm vary independently from clients that use it. For instance, a class that performs validation on data may use different validation algorithms or strategies based on factors like the data type or source that are not known until runtime.

Uploaded by

Rakesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

In computer programming, the strategy pattern (also known as the policy pattern) is a software

design pattern that enables an algorithm's behavior to be selected at runtime. The strategy
pattern

defines a family of algorithms,

encapsulates each algorithm, and

makes the algorithms interchangeable within that family.

Strategy lets the algorithm vary independently from clients that use it.[1] Strategy is one of the
patterns included in the influential book Design Patterns by Gamma et al. that popularized the
concept of using patterns in software design.
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, 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 (or even different systems) without code duplication.
The essential requirement in the programming language is the ability to store a reference to
some code in a data structure and retrieve it. This can be achieved by mechanisms such as the
native function pointer, the first-class function, classes or class instances in object-oriented
programming languages, or accessing the language implementation's internal storage of code
via reflection.

You might also like