Dedian  
-- 关注搜索引擎的开发
日历
<2006年4月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456
统计
  • 随笔 - 82
  • 文章 - 2
  • 评论 - 228
  • 引用 - 0

导航

常用链接

留言簿(8)

随笔分类(45)

随笔档案(82)

文章档案(2)

Java Spaces

搜索

  •  

积分与排名

  • 积分 - 65030
  • 排名 - 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 阅读(227) 评论(0)  编辑  收藏 所属分类: Design Patterns

只有注册用户登录后才能发表评论。


网站导航:
 
 
Copyright © Dedian Powered by: 博客园 模板提供:沪江博客