Composite
Implementation
There are many issues to consider when implementing the Composite pattern:
-
-
-
-
-
-
-
-
- What's the best data structure for storing components?
Composites may use a variety of data structures to store their
children, including linked lists, trees, arrays, and hash tables. The
choice of data structure depends (as always) on efficiency. In fact,
it isn't even necessary to use a general-purpose data structure at
all. Sometimes composites have a variable for each child, although this
requires each subclass of Composite to implement its own management
interface. See
Interpreter for an example.