# Strategy Pattern

> A design pattern that puts each interchangeable algorithm behind one interface, so the caller selects behavior by passing an object.

Record: `architecture:strategy-pattern`
Kind: pattern
Layer: [Design Patterns Core](https://banes-lab.com/records/layer/design-patterns-core.md)
Severity: recommended
Scope: algorithm, policy, behavior
Canonical: https://banes-lab.com/ontology#architecture-strategy-pattern

Listed in [Architecture principles](https://banes-lab.com/api/records/architecture.md), after [Dashboards](https://banes-lab.com/records/architecture/dashboards.md) and before [Template Method Pattern](https://banes-lab.com/records/architecture/template-method-pattern.md).

## Repair

- Refactored by: Extract Strategy
- Detected by: conditional strategy selection with duplicated behavior
- Violated by: switch over behavior modes
- Measured by: conditional complexity
- Enforced by: complexity thresholds, [review](https://banes-lab.com/records/lexicon/review.md)

## Requires

- [Interchangeable Algorithms](https://banes-lab.com/records/lexicon/interchangeable-algorithms.md)

## Reinforces

- [Open/Closed Principle (OCP)](https://banes-lab.com/records/architecture/open-closed.md)
- [Polymorphism](https://banes-lab.com/records/architecture/polymorphism.md)

## Enables

- [Runtime Behavior Selection](https://banes-lab.com/records/lexicon/runtime-behavior-selection.md)

## Conflicts with

- [Large Conditional Logic](https://banes-lab.com/records/lexicon/large-conditional-logic.md)

## In tension with

- [Class Count](https://banes-lab.com/records/lexicon/class-count.md)

## Tensions

- [Strategy Pattern / Class Count](https://banes-lab.com/records/tension/class-count-strategy-pattern.md)

## Severity

- [recommended](https://banes-lab.com/records/vocabulary/severity-recommended.md)

## Category

- [Behavioral Patterns](https://banes-lab.com/records/architecture-category/behavioral-patterns.md)

## Enabled by

- [Composition Over Inheritance](https://banes-lab.com/records/architecture/composition-over-inheritance.md)

## Linked from

- [Core Modular Design](https://banes-lab.com/ontology/principles/architecture-category-core-modular-design.md)
- [SOLID / Object-Oriented Design](https://banes-lab.com/ontology/principles/architecture-category-solid-object-oriented-design.md)
- [Behavioral Patterns](https://banes-lab.com/ontology/lexicon/lexicon-category-behavioral-patterns.md)
- [Severity levels](https://banes-lab.com/ontology/schema/the-vocabulary-severity.md)
- [The resolutions](https://banes-lab.com/ontology/schema/the-resolutions.md)
