Design Patterns : Composite pattern
Frequently programmers develop systems in which a component may be an individual object or it may represent a collection of objects.
Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
Use the Composite pattern when;
- You want to represent part-whole hierarchies of objects
- You want clients to be able to ignore the difference between compositions of objects and individual objects. Clients will treat all objects in the composite structure uniformly.
•A composite is a container that may hold either individual objects or other compositions.
•Common behaviors may appear in both individual objects and compositions.