iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 22
1
Software Development

保持前進、持續優化程式碼內涵系列 第 20

22. 樣板方法模式- Template Method (未完, 待補)

Sorry, 先卡位, 後補文

前面提到了 Factory Method ,今天來聊聊跟 Factory Method 很相似的 Template Method。

Template Method 在 GoF 所定義的類別中,屬於行為模式(Behaviroal design pattern)

1. 可以解決怎麼樣的需求?

  • The invariant parts of a behavior should be implemented only once so that subclasses can implement the variant parts.
  • Subclasses should redefine only certain parts of a behavior without changing the other parts.

2. 作法

3. 注意事項

4. Factory Method vs. Template Method

5. 後言

推薦

同場加映


上一篇
20. 簡單工廠模式 - Simple Factory
下一篇
24. 建造者模式 - Builder (未寫,待補)
系列文
保持前進、持續優化程式碼內涵24
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言