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
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.
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.
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.