|Definition||The intent of a composite is to “compose” objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly. ||Defines a family of algorithms, encapsulates each algorithm, and makes the algorithms interchangeable within that family. |
|Relation-ship||A tree, and can be recursive abstractly||Flat, a family of algorithms|
|Selection||No, treat in individual objects and compositions uniformly||Yes, select one algorithm from a family|
|Delegation||Yes, theoretically the action can be populated down the tree simultaneously||No|
Composite is a pattern with a set of attributes and Strategy is a pattern with another set of attributes. It is interesting to see the permutation and combination of these attributes of two patterns.
As a starter, my questions are:
- What if we combine Composite and Strategy as one in an object, we can look at the Composite as the state of the object and Strategy as the behavior of the object.
- What if we apply Composite to one or all algorithms of that family
- What if we apply Strategy to a node or all nodes of a Composite
- Gamma, Erich; Richard Helm; Ralph Johnson; John M. Vlissides (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley.