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

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
主站蜘蛛池模板: 阿图什市| 定兴县| 梅河口市| 水城县| 马公市| 宣化县| 澄城县| 博乐市| 武隆县| 东明县| 鄢陵县| 灵宝市| 沽源县| 浮梁县| 香河县| 白银市| 曲水县| 广水市| 法库县| 北京市| 女性| 盐津县| 安溪县| 称多县| 东阿县| 云南省| 永年县| 松滋市| 通许县| 原平市| 嘉鱼县| 聂荣县| 同德县| 兰西县| 汕头市| 岑巩县| 北京市| 吉木萨尔县| 永丰县| 济南市| 寿宁县|