Skip to content

Latest commit

 

History

History
19 lines (16 loc) · 597 Bytes

README.md

File metadata and controls

19 lines (16 loc) · 597 Bytes

DesignPattern

Practice design patterns and UML

Factory Method

使用時機:
在無法明確知道要產生的類別會是哪一種物件型態時使用
讓子類別去決定要產生哪一種物件型態
有幾種方式可採用:

  • 參數方式
  • 指定類別變數
  • 多工廠指定不同類別(以下範例)

Alt text

Builder

使用時機:
有固定的生產流程或是標準化步驟
統一由Director執行一系列的流程,指揮Builder進行組裝
Alt text