JunsuLime / spring-cloud-native-explorer

Spring cloud explorer
1 stars 0 forks source link

Command Pattern 을 알아보자. #44

Open JunsuLime opened 2 years ago

JunsuLime commented 2 years ago

https://ko.wikipedia.org/wiki/%EC%BB%A4%EB%A7%A8%EB%93%9C_%ED%8C%A8%ED%84%B4 https://en.wikipedia.org/wiki/Command_pattern

In object-oriented programming, the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time. This information includes the method name, the object that owns the method and values for the method parameters.

행위 기반으로 객체를 캡슐화하는 패턴

즉, 행위가 늘어나는 경우에 대해 유효하게 사용할 수 있을 것으로 보인다. (행위 마다 구현체가 늘어나는 형태로 구현 가능)

object is used to encapsulate all information needed to perform an action or trigger an event at a later time.

JunsuLime commented 2 years ago

커맨드 패턴이란?

the command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time.

행위 기반으로 캡슐화를 한 디자인 패턴이다. 행위의 이름을 정보로 가지고 있으며, 행동을 수행하기 위한 변수를 가지고 만들어진다.

커맨드 패턴 관련 용어

커맨드 패턴을 사용한 before after

before

after

핫픽스의 경우를 생각해보자.

유입된 이벤트 기반으로 행위가 정해는 유즈케이스였고 특정이벤트를 처리하는 A라는 행위가 추가되었다.

파일 하나 추가, command 를 만드는 factory 에 코드 추가로 기존 코드에 영향도가 거의 없었다.