その先にあるもの…

State 패턴 본문

프로그래밍/패턴

State 패턴

specialJ 2015. 4. 7. 21:14

UML class diagram




Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.


Context객체가 상태에 따라 기능을 달리 할 때 사용하는 패턴이다.

Context객체는 State 객체를 가지고 있으며 상태가 변할때 마다 각 상태에 따라 ConcreteState를 교체해 사용한다.



사용후기

Context 객체내부는 각 상태에 따른 분기문(IF, SWITCH)이 없어져 코드가 깨끗하다.



도움

http://www.dofactory.com/net/state-design-pattern

'프로그래밍 > 패턴' 카테고리의 다른 글

stragy패턴  (0) 2015.04.09
Decorator  (0) 2014.05.22
observer  (0) 2014.04.07
Comments