This chapter covers the Composite pattern.
GoF Definition
It composes objects into tree structures to represent part-whole hierarchies. The Composite pattern lets clients treat individual objects and compositions of objects uniformly.
Concept
Consider a shop that sells different kinds of dried fruit such as cashews, dates, and walnuts. Each item has a certain price. Let’s assume that you can purchase individual items or you can purchase gift packs (or boxed items) which are composed of different dried fruit items. In this ...