Jump to content

Talk:Composite pattern

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by ZooFari (talk | contribs) at 03:44, 10 November 2009 (Adding WikiProject Java assessments per request (Mistake?) using AWB). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
WikiProject iconJava Unassessed
WikiProject iconThis article is within the scope of WikiProject Java, a collaborative effort to improve the coverage of Java on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
???This article has not yet received a rating on Wikipedia's content assessment scale.
???This article has not yet received a rating on the project's importance scale.
WikiProject iconComputer science Start‑class
WikiProject iconThis article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
StartThis article has been rated as Start-class on Wikipedia's content assessment scale.
???This article has not yet received a rating on the project's importance scale.
Things you can help WikiProject Computer science with:

This has to be one of the most unprofessional UML diagrams I've seen for one of the most common patterns. As per the user above's complaint about the PERL, Java would be a better language, but in interest of neutrality I'd suggest doing the whole thing in a UML sequence diagram to maintain language neutrality. And can't someone with the GoF CD just quote and paste portions outlining the GoF example -- it's much better.

I added two links to discussions on the pattern. What is needed is a realistic example. For instance an example where the pattern is not used and then how refactoring it leads to the pattern. I have found several moderetaly convincing examples on the web but no really convincing one. Concerning language neutrality: UML sequence language is no more neutral than C++ or Java. MikalZiane 12:44, 26 June 2006 (UTC)[reply]

I believe the quality of this article is the code examples as there is nowhere else on the web that both explains the theory and show concrete implementations. A encyclopedia should contain an explanation and history and/or a picture and/or video sequence and/or map and/or examples and/or links to other resources of a given topic. This article only does half and should therefore not be shorten in anyway that will limit the way it elaborate on the topic "Composite pattern". Someone should update (or add) a C# 2.0 example with generics. Also an example in Smalltalk should be added for completeness (a C# 2.0 implementation with the [C5] library and a Java implementation with the Java Collections Framework could also be added). --DotnetCarpenter 09:42, 1 November 2006 (UTC)[reply]

I think the article would be a lot better if the code examples were consistent with the UML diagram and its explanation. The abstract Component class is stated to "declare the interface for objects in the composition" and "implement default behavior for the interface common to all classes, as appropriate". Neither of these can be seen implemented in the example code. Should the examples be changed to follow the diagram? Should the benefits and drawbacks of having a more complete vs. simple interface in Component class (cf. GoF book items 3 and 4 on pages 167-169) be mentioned, too? --Uffis (talk) 10:51, 12 June 2008 (UTC)[reply]

Composite c++ example

I changed the c++ example the old one was awful: horribly indented, compiled with many warnings, segfaulted, obfuscated, etc. This one I believe is much better and doesn't have any warnings under: g++ -o test test.cpp -Wall -pedantic -ansi. Let me know what you think--Michael miceli (talk) 02:43, 30 March 2008 (UTC)[reply]

Bad class design

In UML diagram, the Component should not have methods to manage children components (add, remove and getChild) because the Leaf class which inherit from the Component class should not have child components. Those methods should not exists in the Leaf class. When the component tree is built, the add and remove methods are called using a Composite class instance instead of a Component interface reference.

--DavidL (talk) 13:48, 9 May 2009 (UTC)[reply]