Composite of composite? (help needed)
Hi.
I'm writing an app that reads an xml doc and creates an object model from it.
The basic model is this:
At the top level, you have a Project. The Project contains Modules. The Modules can depend on (contain) other Modules, but can also depend on Libraries. In turn, each Library can depend on other libraries.
On top of that, I need to make sure that I only create a single shared instance of each module and library. (for instance, i create library-A which can be used by many modules)
I'm thinking I need to use some sort of composite pattern, but I'm confused cause it seems like I have 2 types of composites but they need to be related.
Just for clarity, here's a simple visual that might explain what i could have at runtime:
(just the objects defined):
Project (myProject)
Module (coolModule) [depends: dumbModule, simpleLib]
Module (okModule) [depends: simpleLib]
Module (dumbModule)
Library (simpleLib) [depends otherLib]
Library (otherLib)
(the tree):
Project (myProject)
Module (coolModule)
Module (dumbModule) (can also be accessed from project)
Library (simpleLib)
Library (otherLib)
Module (okModule)
Library (simpleLib)
Library (otherLib)
I hope this makes sense....
Can anyone tell me if I can use composite for this? If not, is there a good way (patterns or no) to do this?
Thanks!
- Jonathan

