C.Composite
Summary
Composite patterns are uses to implement whole – part relationship and mostly utilized to implement tree data structure.
The intent of this pattern is to compose objects (Node) into tree structures to represent part-whole hierarchies.
Client treats Composite (node) and individual objects (leaf) uniformly.
Tutorials
When to Use
The composite pattern applies when there is a part-whole hierarchy of objects and a client needs to deal with objects uniformly regardless of the fact that an object might be a leaf or a branch.
Graphics Editors use composite pattern to implement complex and simple graphics as previously explained.
File System implementations use the composite design pattern as described previously.
Specific Considerations
Composite Vs Decorator
Decorator is often used with Composite. When decorators and composites are used together, they will usually have a common parent class
So decorators will have to support the Component interface with operations like Add, Remove, and GetChild.