Implementation Issues
Implementing Child-Related Operationsadd(child)),
removing a child component from the container (remove(child)),
and accessing a child component (getChild()).
Variant 1: Design for Uniformity
Component interface.
Leaf and Composite
objects uniformly.
Leaf and Composite interfaces (types) are not cleanly separated.
Component class implements
default behavior for child-related operations
like "do nothing" or
"throw an exception".
The Leaf class inherits the default
implementations,
and Composite must redefine them.
Variant 2: Design for Type Safety
Composite class.
Leaf components).
Leaf and Composite objects differently.