Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Design Pattern & UML  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:Decorator 与 Composite 模式? [Re:jameszhang]
sanshaoye





发贴: 16
积分: 0
于 2004-11-19 12:16 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I don't think so.

The first,consider the purpose of those two pattern

The Composite Design pattern allows a client object to treat both single components and collections of components identically.

If you read the junit code, you can found TestSuite composite a collections of TestCase,they implements the common interface Test,so you can treat TestSuite and TestCase identically.If you run a TestSuite will run all TestCase of that include.

The Decorator Pattern is used for adding additional functionality to a particular object as opposed to a class of objects.

Consider,we will and some function for your class exist already. It is easy to add functionality to an entire class of objects by subclassing an object, but it is impossible to extend a single object this way. With the Decorator Pattern, you can add functionality to a single object and leave others like it unmodified.



Nothing is impossible to a willing heart!

话题树型展开
人气 标题 作者 字数 发贴时间
15567 Decorator 与 Composite 模式? jameszhang 57 2004-11-19 10:51
14131 Re:Decorator 与 Composite 模式? sanshaoye 899 2004-11-19 12:16
13790 Re:Decorator 与 Composite 模式? floater 905 2004-11-22 13:26
13456 Re:Decorator 与 Composite 模式? jameszhang 962 2004-12-02 11:24
13492 Re:Decorator 与 Composite 模式? jameszhang 1270 2004-12-02 16:03
13430 Re:Decorator 与 Composite 模式? floater 416 2004-12-02 23:33
13667 Re:Decorator 与 Composite 模式? jameszhang 511 2004-12-03 08:01
13432 Re:Decorator 与 Composite 模式? floater 124 2004-12-03 23:08
14509 Re:Decorator 与 Composite 模式? jameszhang 173 2004-12-04 10:13
13641 Re:Decorator 与 Composite 模式? emarket 512 2004-11-21 14:18
13562 Re:Decorator 与 Composite 模式? jameszhang 56 2004-11-22 09:17
13566 Re:Decorator 与 Composite 模式? emarket 134 2004-11-22 10:27
13547 Re:Decorator 与 Composite 模式? wes109 269 2004-11-22 10:56
13525 Re:Decorator 与 Composite 模式? jameszhang 62 2004-11-22 11:28
13566 Re:Decorator 与 Composite 模式? emarket 251 2004-11-23 13:46
13609 Re:Decorator 与 Composite 模式? wes109 230 2004-11-22 11:46
13505 Re:Decorator 与 Composite 模式? jameszhang 108 2004-11-22 11:55
13526 Re:Decorator 与 Composite 模式? wes109 207 2004-11-22 13:13

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923