Composite
Implementation
There are many issues to consider when implementing the Composite pattern:
-
-
-
-
-
- Child ordering.
Many designs specify an ordering on the children of Composite. In the
earlier Graphics example, ordering may reflect front-to-back ordering.
If Composites represent parse trees, then compound statements can be
instances of a Composite whose children must be ordered to reflect the
program.
When child ordering is an issue, you must design child access and
management interfaces carefully to manage the sequence of children.
The
Iterator pattern can guide you in this.