difference between decorator and composite?

T

thomas

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

Victor Bazarov

thomas said:
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
 
J

jun Wang

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?

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

Gil

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top