Skip to content

Instantly share code, notes, and snippets.

@linearhw
Created January 5, 2018 08:48
Show Gist options
  • Save linearhw/5d16acacd58c9e0b0fc34a736c116dc0 to your computer and use it in GitHub Desktop.
Save linearhw/5d16acacd58c9e0b0fc34a736c116dc0 to your computer and use it in GitHub Desktop.

State

언제 사용하면 좋은가

  • 내부 state 변화에 따라 객체도 바뀌어야 할 때
  • 각 state 에서 해야 할 behavior 가 모두 새로운 state 가 추가될 가능성이 있을 때

특징

  • state 에 따른 behavior 를 모두 캡슐화하고, state 의 interface 를 분리한다.
  • 지나치게 길어진 switch 문을 짧게 만들 수 있다.

예제

  • ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment