Glossary · Automation software engineering and architecture
Strategy pattern
Also known as: Policy pattern
German: Strategiemuster
In software design, the strategy pattern is a design pattern that defines a family of interchangeable algorithms behind a common interface, so the algorithm used can be selected at run time without changing the code that uses it.
- Software engineering
In one sentence
The strategy pattern puts interchangeable algorithms behind a common interface so the one used can be selected at run time.
Example
The palletizer selects a stacking strategy per product type, each implemented as a function block with the same interface.
How it applies
- Engineering: The pattern suits variants of one function, such as different control algorithms, sorting rules or communication formats. New variants can be added without touching the calling code.
- Configuration: The selected strategy is often part of the machine configuration; it must be recorded and validated like other parameters.
- Documentation: Users see strategies as options, such as modes or methods. Document each option's behavior, when to use it and how to select it; a comparison table helps.
Strategy pattern vs. state pattern
In the strategy pattern, the choice of algorithm is made from outside and stays until changed. In the State pattern, the object changes its behavior itself when its state changes.