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

  • Spring 5 Design Patterns
  • Dinesh Rajput
  • 210字
  • 2021-07-08 09:59:38

UML structure of the Composite design pattern

Composite design pattern is based on the composition of similar types of objects into the tree structure, as you know that each tree has three main parts branch, node, and leaf. So let's have a look at the following terms used in this design pattern.

Component: It is basically a branch of the tree and the branch has other branches, nodes, and leaves. Component provides the abstraction for all components, including composite objects. In the composition pattern, component is basically declared as an interface for objects.

Leaf: It is an object that implements all component methods.

Composite: It is represented as a node in the tree structure, it has other nodes and leaves, and it represents a composite component. It has methods to add the children, that is, it represents a collection of the same type of objects. It has other component methods for its children.

Let's look at the following UML diagram for this design pattern:

UML diagram for the Composite Design Pattern

Benefits of the Composite design pattern

  • This pattern provides the flexibility to add new component to process dynamically, with change in the existing components
  • This pattern allows you to create a class hierarchy that contains individual and composite objects
主站蜘蛛池模板: 襄垣县| 杭锦后旗| 泾阳县| 龙胜| 宽甸| 茶陵县| 辉县市| 昌黎县| 颍上县| 呼图壁县| 三原县| 讷河市| 陆川县| 女性| 海阳市| 岗巴县| 元氏县| 沭阳县| 衡山县| 汉源县| 固阳县| 响水县| 宜黄县| 徐州市| 武山县| 万年县| 黑水县| 叙永县| 长治县| 呼和浩特市| 永州市| 澄迈县| 兴山县| 钟山县| 沾化县| 芦溪县| 开化县| 北川| 灵宝市| 宁德市| 宣城市|