- 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:

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
- 密碼學原理與Java實現
- Java開發入行真功夫
- Java Web開發技術教程
- Rust Essentials(Second Edition)
- Linux Device Drivers Development
- 劍指Java:核心原理與應用實踐
- Julia高性能科學計算(第2版)
- Java編程的邏輯
- PHP從入門到精通(第4版)(軟件開發視頻大講堂)
- Scala for Machine Learning(Second Edition)
- 零基礎學Scratch 3.0編程
- 區塊鏈架構之美:從比特幣、以太坊、超級賬本看區塊鏈架構設計
- 零基礎學C++(升級版)
- Python第三方庫開發應用實戰
- Mastering Clojure