mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-09-25 22:09:23 +02:00
17 lines
416 B
Markdown
17 lines
416 B
Markdown
# Strategy
|
|
|
|
## Terminology:
|
|
|
|
* Context
|
|
* Strategy
|
|
* Concrete Strategy
|
|
|
|
## Purpose
|
|
|
|
To separate strategies and to enable fast switching between them. Also this pattern is a good alternative to inheritance (instead of having an abstract class that is extended).
|
|
|
|
## Examples
|
|
|
|
* sorting a list of objects, one strategy by date, the other by id
|
|
* simplify unit testing: e.g. switching between file and in-memory storage
|