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

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
主站蜘蛛池模板: 新绛县| 资阳市| 那曲县| 汽车| 澎湖县| 垫江县| 全南县| 郓城县| 饶平县| 汝城县| 木里| 林口县| 漠河县| 延津县| 汝州市| 庆元县| 万盛区| 衡阳县| 江永县| 唐山市| 嘉兴市| 民和| 玛多县| 七台河市| 巴青县| 铜川市| 靖远县| 隆回县| 西丰县| 宁明县| 常德市| 南充市| 廉江市| 贵阳市| 屏东县| 太原市| 水富县| 沈阳市| 宜城市| 达日县| 玉屏|