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

          導航

          常用鏈接

          留言簿(8)

          隨筆分類(45)

          隨筆檔案(82)

          文章檔案(2)

          Java Spaces

          搜索

          •  

          積分與排名

          • 積分 - 66105
          • 排名 - 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: 博客園 模板提供:滬江博客
          主站蜘蛛池模板: 巩留县| 修文县| 炎陵县| 宜兰市| 格尔木市| 张掖市| 当阳市| 秦安县| 乌什县| 罗源县| 全州县| 开封市| 璧山县| 贞丰县| 蒲城县| 三都| 天镇县| 本溪市| 育儿| 甘泉县| 汝城县| 西乌珠穆沁旗| 武清区| 色达县| 济阳县| 武乡县| 札达县| 上思县| SHOW| 汕尾市| 祁连县| 瑞安市| 米脂县| 保定市| 金门县| 阳西县| 永兴县| 德庆县| 昌乐县| 新沂市| 富裕县|