Detailed Explanation of Class Diagram

Class Diagram

1. Class Diagram Summary

​ ★The main purpose of the class diagram is to reflect the structure of the class (attributes, operations) and the relationship between the classes. It describes the structure of the software system and is a static modeling method.

​ ★The "class" in the class diagram corresponds to the concept of "class" in the object-oriented language, which is an abstraction of things in the real world
insert image description here

2. Things and explanations in the class diagram

​ (1) Category

1. It is divided into three parts from top to bottom, namely class name, attribute and operation. class name is required

​ 2. If a class has attributes, each attribute must have a name, and can also have other descriptive information, such as visibility, data type, default value, etc.

3. If the class has operations, each operation also has a name, and other optional information includes visibility, parameter names, parameter types, parameter default values, and the type of return value of the operation, etc. (2
insert image description here
) interface

​ A set of operations, only the declaration of the operation but no implementation

(3) Abstract class

​ A class that cannot be instantiated, generally contains at least one abstract operation

(4) Template class

A parameterized class that binds template parameters to different data types at compile time, resulting in different classes

insert image description here

3. The relationship and explanation in the class diagram

​ (1) Association relationship - describes the relationship between the structure of the class. Has information such as direction, name, role, and multiplicity. General association semantics are weak. insert image description hereinsert image description here
There are also two strong semantics, namely aggregation and combination

​ 1. Aggregation relationship - special association relationship, indicating the relationship between an aggregate (whole) and its components
insert image description here
2. Composition relationship - aggregation with stronger semantics, part and whole have the same life cycle
insert image description here
insert image description here

(2) Generalization relationship——※In object-oriented, it is generally called inheritance relationship, which exists between parent class and subclass, parent interface and subinterface. (3) Realization relationship insert image description here
insert image description here
—corresponding to between classes and interfaces The relationship
insert image description here
insert image description here
​ (4) Dependency relationship - ※ describes the situation in which a change in a class affects the class that depends on it. There are many forms of expression, such as binding (bind), friend (friend), etc. insert image description here
insert image description here
4. Mapping between class diagrams and codes

(1) Class mapping
insert image description here

(2) Mapping of association relationship
insert image description here
(3) Mapping of generalization relationship
insert image description here
(4) Mapping of realization relationship
insert image description here
(5) Mapping of dependency relationship
insert image description here
5. Example of class diagram

(1) Graphics editor
insert image description here

​ (1) Performance Ticketing System
insert image description here


Article content extended learning link

UML overview

Detailed use case diagram

Detailed sequence diagram

Collaboration Diagram Detailed

Detailed state diagram

Detailed explanation of activity diagram

Detailed explanation of component diagram

Detailed deployment diagram

Guess you like

Origin blog.csdn.net/qq_40332045/article/details/104026423