aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Composite design pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Composite design pattern" Watch "Composite design pattern" New topic
Author

Composite design pattern

meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

Hi,
i created this program from my understanding, do you think this is correct example of composite design pattern ?




My one regret in life is that I am not someone else.
- Woody Allen
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4387
    
    8

No, because all that allows you to go is have a Composite containing a single Leaf. The idea behind the composite pattern is to allow you to build a hierarchy of grouped objects. So what you need is to implement it so that each Composite object can contain multiple Component objects (not just Leafs). That way you can put Composites inside Composites.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Composite design pattern