If you haven’t read the previous article on class diagram entities, the link is here: UML Anatomy (1) — Class diagram entities. This section continues with StarUML.

1. Class diagram association

Let’s go through the correlation properties shown above one by one.

1.2 Association

Association is a two-way Association. For example, teachers and students have a two-way Association. Examples are as follows:

Student’s 1.. * means one to multiple, i.e., one Teacher object corresponds to multiple students.

1.3 Directed Association

This association means directional association, as shown in the following figure:

The associated class B appears in class A as A class attribute.

1.4 Aggregation

This means aggregation, which shows the relationship between the whole and the parts.

A School class has one or more Student classes.

1.5 Composition

Is a stronger Aggregation than Aggregation, similar to the relationship between a pregnant woman and the fetus. The fetus is attached to the pregnant woman, and if the pregnant woman dies, the fetus cannot survive. Here is an example:

1.6 the Dependency

What this means is that one class depends on another class, for example one class as a parameter in another class’s method as a call.

1.7 Generalization

What this means is a generalization relationship, the inheritance of one class to another. Here is what A inherits from B.

1.8 Interface Realization

This is also very simple, is the meaning of interface implementation. Here is an example:

2. Sequence diagram

2.1 define

A sequence diagram is simply the chronological order in which messages pass between objects. For now, StarUML is used to explain the elements of the sequence diagram.

2.2 there is

This means an object, as shown in the following figure:

2.3 the Message

This means to send a common message, such as a user to send a login message to the server, as shown in the following figure:

2.4 the Self Message

For example, one method of an object calls another method of the object, as shown in the following figure:

2.5 Async Message

This means asynchronous message, as shown in the following figure:

The User sends a Login message to the Server, and the Server sends a save User message to the database. Note that the message is asynchronous.

2.6 the Reply Message

This means a callback message, as shown in the following figure:

After the User sends the Login message to the Server, the Server sends the asynchronous message to the database and the Login result to the User.

2.7 the Create Message

This means to create an object, as shown in the following image:

2.8 Delete the Message

This means to destroy an object, as shown in the following figure:

2.9 Async Signal Message

This means to send a signal message, meaning that when one object meets a certain condition, it automatically sends a signal message to another object, similar to the observer mode.

2.10 Found the Message

This means to send a message from an unknown source, as shown in the following figure:

2.11 Lost the Message

This means that the message was sent to a place where the source is unknown.

2.12 the Endpoint

This means an unsourced message object, as shown below:

2.13 Gate

The meaning of this is to interact with messages outside the sequence diagram and inside the diagram, as illustrated in the following figure:

The square above is Gate.

2.14 the State Invariant

This means to constrain an object to be in a certain state, as shown in the following figure:

The Task must be in the Finish state before start starts.

2.15 Combined fragments

The translation of this is called composite fragments, and it is used to address the conditions and modes of interactive execution. There are several commonly used combination fragments:

type The name of the instructions
Alt (alternatives) choose Contains a fragment list that has alternate message sequences, one at a time
Opt (option) options Contains a sequence of messages that might occur
Loop (iteration) repeat Contains a message sequence that can be repeated
Par (parallel) parallel Contains a sequence of messages that can be parallel
Break (break) interrupt If this part is executed, the execution of the rest of the sequence is abandoned and can be used to interrupt the loop fragment

Here are some examples:

2.15.1 Alt (Alternatives)

If a > 1 is satisfied, Message1 will be executed, otherwise Message2 will be executed.

2.15.2 opt (option)

Message1 is executed when a > 1 is satisfied.

2.15.3 Loop (Iteration)

Message1 message is sent repeatedly. If you want to limit the number of loops, you can also use the following image:

That means the cycle has been repeated 10 times.

2.15.4 PAR (Parallel)

The figure above means sending three messages in parallel.

2.15.6 Break (break)

When a > 0, it breaks out of the loop and sends a message to ClassC.

These are the commonly used combination fragments. If you are interested in other fragments, you can study them by yourself. I won’t go into details here.

2.16 the Continuation

The meaning of this is what this sequence does.

2.17 Interaction Use

This is used to describe the interaction between two objects. For example:

The User takes id and password as arguments, and UserManager returns result as the result.

Reference books and articles:

UML and Pattern Application

Elephant: Thinking in UML

UML Message

UML Sequence Diagrams