- 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
- iOS Game Programming Cookbook
- Spring 5企業級開發實戰
- 算法零基礎一本通(Python版)
- Learning Chef
- Vue.js 3.0源碼解析(微課視頻版)
- Android底層接口與驅動開發技術詳解
- Visual Basic程序設計上機實驗教程
- Getting Started with React Native
- 計算機應用基礎案例教程
- 搞定J2EE:Struts+Spring+Hibernate整合詳解與典型案例
- Spring技術內幕:深入解析Spring架構與設計原理(第2版)
- OpenCV Android Programming By Example
- 深入解析Java編譯器:源碼剖析與實例詳解
- Learning Alfresco Web Scripts
- 絕密原型檔案:看看專業產品經理的原型是什么樣