Dedian  
          -- 關注搜索引擎的開發
          日歷
          <2006年4月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456
          統計
          • 隨筆 - 82
          • 文章 - 2
          • 評論 - 228
          • 引用 - 0

          導航

          常用鏈接

          留言簿(8)

          隨筆分類(45)

          隨筆檔案(82)

          文章檔案(2)

          Java Spaces

          搜索

          •  

          積分與排名

          • 積分 - 66098
          • 排名 - 813

          最新評論

          閱讀排行榜

          評論排行榜

           
          Purpose:
          Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compostions of objects uniformly.

          Structure:
          The composite object contains other primitive objects(or say Components), and has the same operation as in those primitive objects. Thus we can operater the composite object with the same operations as a whole. Or in other word, composite object is a container of primitive ojects and itself is derived from same base (abstract) class as primitives, so that it can have same operations as primitives. Actually, we can say that the abstract class represents both primitives and their containers

          Implementation:
          -- Extend a base class that represents primitive objects. And the same operation(override function) will be implemented by iterating over that collection and invoking the appropriate method for each component in the collection.
          -- Add & Remove function (for component collection) will be defined in base class, though it is meaninglessful for leaf classes.

          reference:
          http://www.javaworld.com/javaworld/jw-09-2002/jw-0913-designpatterns.html
          http://www.codeproject.com/useritems/Composite.asp

          example:
          http://java.sun.com/blueprints/patterns/CompositeView.html
          posted on 2006-04-20 08:52 Dedian 閱讀(237) 評論(0)  編輯  收藏 所屬分類: Design Patterns
           
          Copyright © Dedian Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 昭通市| 永宁县| 万荣县| 广河县| 九龙城区| 洪泽县| 龙川县| 双流县| 砀山县| 彰化县| 曲麻莱县| 尼勒克县| 彩票| 肃南| 和田县| 板桥市| 沐川县| 福清市| 奎屯市| 揭西县| 锡林郭勒盟| 泗洪县| 高淳县| 墨玉县| 三明市| 延川县| 寿光市| 奇台县| 胶南市| 昭通市| 乾安县| 日照市| 金塔县| 安远县| 江孜县| 阜康市| 海晏县| 金秀| 庆阳市| 台湾省| 陇西县|