Composite
Implementation
There are many issues to consider when implementing the Composite pattern:
-
-
-
-
-
-
-
- Who should delete components?
In languages without garbage collection, it's usually best to make a
Composite responsible for deleting its children when it's destroyed.
An exception to this rule is when Leaf objects are immutable and thus
can be shared.