Composite: Boxes Inside Boxes

When the tracker weighs a shipment by asking every item "are you a box or a pallet?", it needs one more nested loop for every level of pallets, and a pallet on a pallet on a pallet gets missed; with the Composite pattern, a box and a pallet answer the same question, and a pallet answers by asking what's on it.

By

Updated

Cheat sheet: Composite: Boxes Inside Boxes
Category
Data Structures
Level
Journeyman
Tags
Composite Pattern, Decorator Pattern, OOP, Recursion, Tree