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

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
主站蜘蛛池模板: 长阳| 财经| 昌乐县| 西乌| 巧家县| 三江| 宽甸| 桑日县| 汕尾市| 周宁县| 威宁| 荣成市| 综艺| 津市市| 抚顺市| 西乡县| 当涂县| 阜城县| 会泽县| 青州市| 西乌珠穆沁旗| 大兴区| 池州市| 西平县| 康定县| 绿春县| 方正县| 大同市| 慈溪市| 库伦旗| 洪泽县| 荥阳市| 泽普县| 五常市| 湖州市| 高陵县| 深水埗区| 天镇县| 西青区| 同德县| 西昌市|