Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M1460

Strategy Pattern

Strategy Pattern
CreateHigh supportDesign Thinking
Included
account_tree

Updated 2026-07-28

Loading revision record…

Summary

In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, the code receives runtime instructions on which of a family of algorithms to use.

Definition

In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, the code receives runtime instructions on which of a family of algorithms to use.

How to use

In computer programming, the strategy pattern (also known as the policy pattern) is a behavioral software design pattern that enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, the code receives runtime instructions on which of a family of algorithms to use.

Mechanism

Refers to a type of behavioral pattern in Design Patterns that encapsulates interchangeable algorithms/strategies, allowing the caller to select different behaviors at runtime.

Practice

In progress 0/4

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

Cases

  • Sorting strategies can be switched; payment method strategies can be selected; compression algorithm strategies can be chosen.

Common pitfalls

  • Too many strategies can lead to class explosion; or forcing logic that should be combined into strategies.
Sources

Source support: Explicit

References currently contain only Wikipedia links; primary sources still need review.

  • link
    zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E7%AD%96%E7%95%A5%E6%A8%A1%E5%BC%8FZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS