1 Preface
You can think of a combination as an entity, which contains other entities of the same type. This structure is like a tree connected by a parent node entity and a child node entity. It is like the genealogy of the same ancestor. In the genealogy, each node has the same surname. The combination structure can be very complex, and its internal representation should not be exposed to the client.
2. Details
2.1 Brief Introduction
The combination mode allows us to combine objects of the same base type into a tree structure. The parent node contains child nodes of the same type. In other words, this tree structure forms a "part-whole" hierarchy. It is a hierarchy that contains both the combination of objects (containers) and a single object as a leaf node (primitive. Other nodes contained in each combination can be leaf nodes or other combinations. This relationship is recursively repeated in this hierarchy.
Combine objects into a tree structure to represent the "part-whole" hierarchy. Combination makes the use of a single object and a composite object consistent.
2.2 When to use
(1) to obtain the abstract tree representation of an object (partial-overall hierarchy );
(2) The client wants to process all objects in the composite structure in a unified manner.
3 conclusion
The above is all content and I hope it will help you.