官术网_书友最值得收藏!

Composite design pattern

Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.
-GoF Design Patterns

In software engineering, the composite pattern comes under the structural design pattern. According to this pattern, a group of objects of the same type are treated as a single object by the client. The idea behind the Composite design pattern is to compose a set of objects into a tree structure to represent a module of a larger structural application. And this structure for clients is a single unit or instance uniformly.

The motivation behind the Composite design pattern is that objects in the system are grouped into the tree structure, and a tree structure is a combination of the node-leaf and branches. In the tree structure, nodes have a number of leaves and other nodes. Leaf doesn't have anything, which means there is no child of leaf in the tree. Leaf is treated as the end point of tree-structured data.

Let's look at the following figure, which represents data in the tree structure in the form of node and leaf:

Tree structured data using nodes and leaves
主站蜘蛛池模板: 休宁县| 喀喇沁旗| 晋城| 平原县| 新乐市| 寿光市| 温州市| 鹿邑县| 洛宁县| 潜江市| 博爱县| 绥中县| 汾阳市| 鄯善县| 上蔡县| 金寨县| 张家口市| 门源| 兴海县| 布拖县| 庆阳市| 府谷县| 梁山县| 乃东县| 桐乡市| 武胜县| 天镇县| 三河市| 塔河县| 武陟县| 潍坊市| 德庆县| 布尔津县| 安吉县| 和林格尔县| 辰溪县| 咸宁市| 封开县| 余姚市| 泗洪县| 新巴尔虎左旗|