ED's Notes
Here is my technical notes. If any comments or errors, please feel free to give feedbacks.
2009/07/13
設計模式小筆記-Prototype Pattern
Prototype Pattern
原型模式
使用時機:
有複製物件的功能需求時
要點:
1. 建立抽象父類別,內有一個 return 此父類別的 clone 方法
2. 子類別實作 clone 方法(在 .NET 裡只要實做 Icloneable 就可以,第一步可省略)
3. 用戶端可呼叫子類別的 clone 方法複製出一個相同的子類別
維基百科上關於 Prototype Pattern 的說明(英文)
維基百科上關於 Prototype Pattern 的說明(中文)
沒有留言:
張貼留言
‹
›
首頁
查看網路版
沒有留言:
張貼留言