일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- C++
- pi
- boost
- SVN
- SSH
- null
- pandas
- if
- Unity
- autovacuum
- sql
- ngui
- 배열
- mysql
- Eclipse
- awk
- FIND
- Shader
- List
- postgresql
- DROP
- with
- sqlite
- conda
- ubuntu
- expect
- dataframe
- 쉘
- c++11
- python
Archives
- Today
- Total
その先にあるもの…
stragy패턴 본문
UML class diagram
Define a family of algorithms, encapsulate each one, and make them interchangeable.
Strategy lets the algorithm vary independently from clients that use it.
State 패턴과 다이러그램은 동일한 모습이지만 차이점이 있다.
State 패턴은 Context의 행동이 상태에 따라 기능이 전체적으로 변경되지만
Strategy 패턴은 내부의 일부분의 알고리즘이 변경된다.
출처
위의 그림을 보면 쉽게 이해 할 수 있다.
Animal클래스의 상속받는 Tiger와 Eagle이 있다.
이 둘은 같은 동물이지만 Cry, Fly가 다르다.
Cry와 Fly를 따로 인터페이스로 만들어 기능별로 만들고 Tiger와 Eagle이 각자의 Cry, Fly를 설정하면 된다.
Comments