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

  • 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
主站蜘蛛池模板: 海盐县| 郓城县| 金华市| 曲靖市| 闽侯县| 锦州市| 泾川县| 长白| 民和| 平安县| 合水县| 宜兰市| 永德县| 商洛市| 新竹市| 会宁县| 中超| 雷波县| 嘉义市| 芜湖市| 榆林市| 栖霞市| 绥芬河市| 明水县| 商南县| 萝北县| 焦作市| 报价| 丹东市| 汤原县| 黔江区| 阆中市| 康乐县| 蒲江县| 宣恩县| 定西市| 武隆县| 上饶市| 大安市| 历史| 莲花县|