본문 바로가기
SW 공부/Design Patterns

[디자인패턴] Builder pattern (빌더 패턴)

by 꼬냉상 2022. 8. 28.

Purpose of Builder Pattern (빌더 패턴의 목적)

- Allows for the dynamic creation of objects based upon easily interchangeable algorithms.

- 쉽게 교환할 수 있는 알고리즘을 기반으로 개체를 동적으로 만들 수 있다.

 

Builder pattern (빌더 패턴)

- 생성 패턴의 한 종류로  전략 패턴의 특화된 형태

- Composite는 Builder가 만드는 것

- Director와 Builder 구조 
 → Director knows what parts are needed for the final product. (Director는 어떤 부품이 필요한지 알고 있고)
→ Concrete builder knows how to produce the part and add it to the final product. (Concrete builder는 최종 product에 추가하는 방법을 안다)

- Participants : Client, Director, Builder, Concrete Builder, Product

 

Related Patterns

- Comparison with Abstract Factory
  : Builder constructs the object step-by-step and the result is requested at a later stage. (단계별로 다 구성하고, 이후 단계에서 결과를 요청함. 단계별 object는 관심 없고, Final Object만 필요함)

  : Abstract factory returns the requested object immediately  (요청된 객체를 즉시 반환, 단계별로 다)

 

Quiz) 다음과 같이 빌더 패턴이 적용된 설계에 대해, 클라이언트가 완성된 복합 객체를 얻어내는 과정을 UML 시퀀스 다이어그램으로 표현하시오.

 

본 글은 개인의 S/W 구조설계 역량 강화를 위한 학습 목적으로 정리된 내용입니다.
일부 타/개인 단체에 저작권이 있는 자료를 포함하고 있으므로, 절대 영리 목적으로 사용하실 수 없습니다.
반응형

댓글