September 2020
Intermediate to advanced
653 pages
10h 37m
English
This chapter covers the Composite pattern.
Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
Consider a shop that sells different kinds of dry fruit, such as cashews, dates, and walnuts. Each of these items has a certain price. Let’s assume that you can purchase any of these individual items, or you can purchase “gift packs” (or boxed items), which are composed of different dry fruit items. In this case, the cost of a packet is the sum of its component ...
Read now
Unlock full access