🌱Aadam's Garden

Search

Search IconIcon to open search

Strategy Pattern

Last updated Aug 16, 2022

Source:: Software Design Patterns - Best Practices for Software Developers


Definition

The strategy pattern is formally defined as encapsulating algorithms belonging to the same family and making them interchangeable. The consumers of the common interface that the algorithms implement allow switching out one algorithm for another seamlessly.

Strategy pattern is useful when we have multiple algorithms for specific task and we want our application to be flexible to chose any of the algorithm at runtime for specific task.

# Resources