Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
According to [Gamma95], the Composite pattern is intended to facilitate building complex (composite) objects from simpler (component) parts by representing the part-whole hierarchies as tree-like structures. This must be done in such a way that clients do not need to distinguish between simple parts and more complex parts that are made up of (i.e., contain) simpler parts.
Figure 8.2 describes the Composite pattern. In this diagram, there are two distinct classes for describing two roles: