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

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
主站蜘蛛池模板: 德化县| 登封市| 增城市| 林西县| 临邑县| 睢宁县| 喀什市| 宁陕县| 阜城县| 留坝县| 内黄县| 民和| 资中县| 永清县| 诸暨市| 景谷| 额济纳旗| 都匀市| 林口县| 南部县| 烟台市| 丹江口市| 若羌县| 肇东市| 永修县| 稻城县| 三河市| 高淳县| 广宁县| 思南县| 东乡族自治县| 英德市| 阳山县| 临高县| 连州市| 长岛县| 井研县| 谷城县| 潍坊市| 高邑县| 佛坪县|