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

  • Spring 5 Design Patterns
  • Dinesh Rajput
  • 194字
  • 2021-07-08 09:59:37

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
主站蜘蛛池模板: 文成县| 夏邑县| 沂水县| 湛江市| 大城县| 鄂托克前旗| 福建省| 读书| 贞丰县| 繁昌县| 安龙县| 瓦房店市| 华坪县| 沁水县| 罗山县| 万州区| 黔西县| 东乌珠穆沁旗| 雷山县| 咸阳市| 黄大仙区| 襄樊市| 泽普县| 麦盖提县| 淮北市| 海盐县| 于都县| 霍山县| 恩平市| 东阿县| 大余县| 越西县| 县级市| 延长县| 紫金县| 明溪县| 西青区| 紫阳县| 成安县| 东莞市| 桦川县|