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

          導航

          常用鏈接

          留言簿(8)

          隨筆分類(45)

          隨筆檔案(82)

          文章檔案(2)

          Java Spaces

          搜索

          •  

          積分與排名

          • 積分 - 65603
          • 排名 - 816

          最新評論

          閱讀排行榜

          評論排行榜

           
          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 閱讀(232) 評論(0)  編輯  收藏 所屬分類: Design Patterns
           
          Copyright © Dedian Powered by: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 措勤县| 叶城县| 临沭县| 彭阳县| 三台县| 新巴尔虎右旗| 民勤县| 昌黎县| 建阳市| 高台县| 张北县| 苏尼特左旗| 莱芜市| 台前县| 弥勒县| 苍山县| 苏尼特右旗| 龙南县| 包头市| 泾阳县| 嘉兴市| 高碑店市| 九龙县| 齐齐哈尔市| 阿拉善右旗| 皮山县| 肇东市| 青海省| 大庆市| 新丰县| 神池县| 右玉县| 灌阳县| 拉孜县| 车致| 新乐市| 勃利县| 怀仁县| 平泉县| 扎赉特旗| 五原县|