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

          導航

          常用鏈接

          留言簿(8)

          隨筆分類(45)

          隨筆檔案(82)

          文章檔案(2)

          Java Spaces

          搜索

          •  

          積分與排名

          • 積分 - 65555
          • 排名 - 817

          最新評論

          閱讀排行榜

          評論排行榜

           
          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: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 临高县| 栖霞市| 松潘县| 惠水县| 海丰县| 大田县| 新竹市| 武乡县| 廊坊市| 巍山| 湾仔区| 阿拉尔市| 安平县| 昂仁县| 保山市| 金门县| 遵化市| 孟州市| 华池县| 廉江市| 左云县| 博罗县| 南宫市| 大渡口区| 平阴县| 米脂县| 句容市| 得荣县| 阿合奇县| 颍上县| 德保县| 清水县| 阿城市| 柞水县| 鹤岗市| 朝阳市| 抚顺市| 怀来县| 山西省| 高碑店市| 邯郸县|