Welcome to “Algorithms and the Beauty of Programming” ↑ pay attention to us!

 

The foreword 0.

I believe that when you learn UML class diagrams, the biggest difficulty probably comes from two aspects:

1) The differences of various relations in the class diagram;

2) Symbol memory of multiple relationships is easily confused;

In keeping with the principle of “Doone thing and do it well.” this article does not cover the differences between relationships in UML class diagrams. This paper mainly introduces the notation theory of UML class diagram and helps us remember it better.

 

1. Prepare

Here’s what you need to know before you start reading:

 

UML class diagram concept;

UML class diagrams have several relationships;

The strength and weakness of relationships;

 

2. Theoretical basis of UML class diagram notation

UML class diagrams have the following relationships:

 

Generalization Generalization

Implementation Realization

Portfolio Composition

The Aggregation Aggregation

Association Association

Relies on the Dependency

 

The strength of these six relationships is:

Generalization > Implementation > Composition > Aggregation > Association > Dependencies

 

Each of these six relationships corresponds to a symbol. That adds up to six symbols, and it is not easy to remember them in a short period of time without confusion. So how do you memorize these symbols more effectively?

 

So let’s first look at the basics of notation.

 

2.1 Basic knowledge of class diagram symbols

First of all, let’s take a look at the symbols of class diagram relations as a whole. The symbols of class diagram relations are composed of three parts: arrows, lines and arrows.

 

There are two kinds of arrowhead shapes, namely arrowhead and triangular arrowhead.

 

There are two kinds of line shapes, solid line and dashed line.

There are three kinds of arrow tail shapes, namely point, hollow diamond and solid diamond.

 

To sum up, we can see that there are 2x 2x 3 = 12 notations for representing class diagram relationships, but there are only 6 relationships in the UML class diagram, so there are 6 unused relationships left.

 

Now that we understand the symbolic representation of class diagram relationships, let’s look at the precedence of symbols.

 

2.2 Symbol priority

From the perspective of the composition of relationship symbols, we define the following priority relationships:

Arrow > Arrow Tail > Lines

 

For arrows:

Triangle arrow > arrow

 

For the tail of an arrow:

Solid diamond > hollow diamond > point

 

For lines:

Solid line > dotted line

 

Therefore, it is not difficult to conclude from the above priorities:

 

Triangle arrow + solid line >

Triangle arrow + dotted line >

Arrow + Solid diamond >

Arrow + Hollow diamond >

Arrow + solid line >

Arrow + dotted line

The six notations above are the six relational notation expressions defined in UML class diagrams.

 

3. The application of

We can use the above symbol theory to easily remember the UML class diagram symbols. Specific memory methods are as follows:

 

Understand the order of strength and weakness of various relationships;

Understand the priority relationship of symbols;

There are a total of 6 symbols of class diagram relationship. We divide them into 3 groups and memorize 2 symbols in each group.

 

First, remember the arrows:

Triangle arrow + solid line

Triangle arrow + dotted line

These two sub-tables represent generalizations and implementations.

 

Next remember the tail of the arrow:

Solid diamond + solid line

Solid diamonds + dashed lines indicate composition and aggregation, respectively.

 

Finally, let’s remember the lines:

Arrow + solid line

Arrows + dashed lines indicate associations and dependencies, respectively.

With such grouping and symbol priority relationships, UML class diagram relationships can be easily remembered without confusion and can be memorable.

 

4. To summarize

This paper mainly introduces the basic knowledge of UML class diagram symbols, and uses the basic knowledge to help you better remember UML class diagram relational symbols.

 

From the basic knowledge of UML class diagram symbols, we analyze that there are 12 symbols in total, but only 6 are used in UML class diagram relations, and the remaining 6 are as follows:

 

Triangular arrow + solid diamond + solid line

 

Triangular arrow + solid diamond + dotted line

 

Triangular arrow + hollow diamond + solid line

 

Triangular arrow + hollow diamond + dotted line

 

Arrow + solid diamond + dotted line

 

Arrow + hollow diamond + dotted line

 

If UML needs to define new class diagram relationships in the future, it can refer to the above notation theory and use the above six notations.