[디자인패턴 수업 4주차 1차시] (수업 용어)디자인 패턴 구성

Jin Hur·2021년 9월 16일
0
post-custom-banner

디자인 패턴 구성

  • Name
  • Intent
  • Motivation
  • Structure
  • Consequence

Strategy pattern 예시

Name: Strategy pattern
Intent: Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
Motivation: Different algorithms are implemented directly(hard-wired), it is impossible to add/change algorithms independently from the context. Wants more flexibility and want to exchange algorithm at run time
Structure:
Consequence:
Pros (+)
1) Avoids compile-time implementation dependencies.
2) rovides a flexible alternative to subclassing.
3) Avoids conditional statements for switching between algorithms.
Cons (–)
1) Can make the common Strategy interface complex.
2) Requires that clients understand how strategies differ.
3) Introduces an additional level of indirection.

post-custom-banner

0개의 댓글