- 추상 알고리즘(Strategy)을 통해 알고리즘을 구현한 부분(ConcreteStrategy)들을 교환 가능
- 알고리즘을 교체해서 동일한 문제를 다른 여러가지 방법으로 해결하는 패턴
- 실행중에 알고리즘의 변경이 가능


1. Strategy (interface)
   - 여러 알고리즘들의 추상 알고리즘의 역할
    - Strategy strategy = new ConcreteStrategy1(); // Strategy strategy = new ConcreteStrategy();

2. Context 
    - Strategy를 구성(Composition) 으로 가지고 있음.
   - Strategy를 구현한 ConcreteStrategy1 or ConcreteStrategy2 의 인스턴스를 통해 알고리즘 변경 가능

3. ConcreteStrategy
   - Strategy 를 구현한 실제 알고리즘들

관련패턴)
   - Flyweight 패턴, Abstract Factory 패턴, State 패턴
Sample)

1. Sort 인터페이스를 구현한 BubbleSort 와 QuickSort 클래스의 sorting() 에 실제 정렬 알고리즘 구현체가 존재
2. ContextSort는 Sort를 구성으로 가지고 contextSorting()에서 알고리즘을 교체한다.


+ Recent posts