preface

UML class diagrams have been used a lot recently, and some of the relationships and use of arrows are documented here

The class diagram defines

Used to describe the structural design of the system, class diagram is the most common UML diagram, which can represent the static structural relations between classes and interfaces.

The class diagram elements

The element

There are two kinds of elements,

1. Interface 2. Class

Relationship between

There are six kinds of relationships

1. Dependency 2. Generalization 3. Aggregation 4. Composition 5

Rely on

A dependency is a superior concept. A class that creates and uses an instance of another class (binding), a class that owns an instance of another class (usage), a subclass that implements a parent class (generalization), and so on are all counted as dependencies. In the class diagram, this relationship is represented by dotted arrows pointing in the direction of dependencies.

generalization

Generalization is the inheritance between classes, and the implementation of the parent class by a subclass is a generalization, which is represented by hollow triangle + solid line in the class diagram

The aggregation

Aggregation is a weak coupling relationship. For example, if a List contains a certain category, it can be regarded as aggregation. The class diagram is represented by hollow diamond + solid line

combination

Focus on describing the association between the whole and the parts. Car needs wheels, so the class of car combines the class of wheels. This relationship is represented by solid diamond + solid line in the class diagram

associated

Relationship is divided into two-way and one-way relationship, such as mobile phones have a lot of app, this is a one-way link the phone app, people and organizations is a two-way, a person may belong to many organizations, organizations will also have a lot of people, this is a kind of bidirectional association, in the class diagram, the relationship with the arrows represent solid lines and openings

implementation

Describes the relationship between the implementation class and the interface implemented, represented by a hollow triangle + dashed line