Dedian |
|
|||
-- 關(guān)注搜索引擎的開發(fā) |
日歷
統(tǒng)計(jì)
導(dǎo)航常用鏈接留言簿(8)隨筆分類(45)
隨筆檔案(82)
文章檔案(2)Java Spaces搜索積分與排名
最新評論
閱讀排行榜評論排行榜 |
Purpose:
Attach additional responsiblities to an object dynamically, which thus provide a flexible alternative to subclassing for extending functionality. Structure: Typically, there will be a parameter to pass original object to decorator object in its constructor, then decorator can implement additional functions within its own interface and apply to original object. when to use: -- when subclassing is not avaible -- when the responsibilities (for different functions) are required flexiable and dynamical -- can not predict combination of extending functionality. (We can not design subclasses for all combination of potential additional functionalities at compile time) reference: Book: Design Pattern (GoF) http://en.wikipedia.org/wiki/Decorator_pattern
|
![]() |
|
Copyright © Dedian | Powered by: 博客園 模板提供:滬江博客 |