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