Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

difference between decorator and composite?

2 views
Skip to first unread message

thomas

unread,
Oct 30, 2009, 5:50:52 AM10/30/09
to
about the two design patterns decorator and composite, both use the
tree structure.
I think they are very similar. Anyone can briefly tell the difference?

Victor Bazarov

unread,
Oct 30, 2009, 8:20:45 AM10/30/09
to
thomas wrote:
> about the two design patterns decorator and composite, both use the
> tree structure.

Says who?

> I think they are very similar. Anyone can briefly tell the difference?

Have you tried asking in 'comp.software.patterns'? Or 'comp.object'?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

jun Wang

unread,
Oct 30, 2009, 12:13:27 PM10/30/09
to

they are used for different purpose. every design pattern have they
ower purpose. and there are some composition or separation or
encapsulation was made to achieve they purpose. so I think if you want
to find out difference between them, you'd better begin with the
purposes of they.

Gil

unread,
Oct 30, 2009, 11:32:37 PM10/30/09
to

probably the question you wanted to ask is what's the difference
between Degenerate Composite (i.e. a Composite with only one
Component) and Decorator.
there is a structural difference, even if the Composite is degenerate
it would still iterate through its Component container.
beside this structural difference (Composite has a container of
Components, Decorator has one component - no need for iteration) there
is a use model difference too:
Decorator usually adds resposibilities to its Component interface
whilst Composite focuses on presenting a Component interface for a
collection of Components.

Daniel T.

unread,
Nov 2, 2009, 6:28:17 AM11/2/09
to
thomas <fresh...@gmail.com> wrote:

Use composite when you want to do the same thing to a bunch of different
objects. Use decorator when you want one object to do something
different.

0 new messages