Why do you need sequence diagram
modeling
We generally describe the process
in 2 ways:
1. Arrange the activities in
chronological order, which is the activity diagram.
See:Activity
diagram.
2. List the objects and describe
the interaction of each object in chronological order,
which is the interaction diagram.
Sequence diagrams are a type of
interaction diagram (in addition, there are communication
diagrams, interaction overview diagrams, and time
diagrams, see:(UML
overview).To describe the process of an
activity, people generally think of an activity diagram,
so why do we need a sequence diagram?
This is because it is impossible
to describe the process without knowing who is responsible
for the various activities of the process. Therefore,
the process must be broken down into responsibilities
for multiple roles/classes/modules. The relationship
and responsibilities of classes are described in a
class diagram (see:Class
diagram), while an activity diagram and
a class diagram are completely different perspectives,
which requires a diagram that depicts the activity
process from the perspective of object interaction.
Take a look at the comparison
of the two legends below:
Here's an analytical design approach
that introduces sequence diagrams:
It can be seen that with the
help of sequence diagrams, we can clearly decompose
activities into object interactions, and then define
class diagrams, so that each behavior has a responsible
person, which is a key part of both business process
analysis and software process analysis:
- Interaction analysis of business
processes allows for someone to take responsibility
for each business effort.
- Interaction analysis of software
processes allows each software function to be held
accountable by modules.
What is there in the sequence
diagram
Any UML diagram has semantics,
elements, relationships, and purposes, and the following
is a list of sequential diagrams:
Semanteme |
Describes the chronological
interaction of several objects |
Element |
object
(object), lifeline, endpoint, diagram gate), state |
Relationship |
Messages
between objects are divided into synchronous calls,
asynchronous messages, and self messages message) |
Use |
You can describe the interaction between business
objects, the interaction between users and the
system, or you can describe the interaction between
system objects. |
Legend: Sequence diagram of
the snake game
In order to make the reader see
more vividly, the usage of the sequence diagram is
introduced in the form of a legend, and the following
is the sequence diagram of the snake game:
Sequence Diagram Description:
- Object interaction rather than class interaction,
because objects can exist in time and have
life.
- Arrange the order of messages according
to the upper and lower positions in time
- The interaction process of sequence diagrams
is irreversible because time passes and history
cannot be repeated.
|
Description of the object:
- Objects generally belong to a certain
class, and there can be multiple objects
of the same kind on a sequence diagram.
- It's a good idea for an object to have
a name so that we can distinguish between
multiple objects of the same kind.
- The process of assigning responsibilities
to the interaction of objects is the process
of assigning responsibilities, which creates
the responsibilities of the class (see:
class diagram);
- The principle of responsibility distribution
is: high cohesion, low coupling, such a
relationship is simple and clear, little
mutual influence, and high execution efficiency.
|
Description of the message:
The message must be sent or received by the
object, so the message also has a long existence;
Messages can't extend beyond the lifecycle of
an object.
There are 3 types of interactive messages:
- Synchronize messages: The object that
sent the message waits for the response
of the object receiving the message, and
then proceeds to Next after the response
is available.
- Asynchronous message: The object that
sends the message continues to do its own
thing after sending the message, without
waiting for the response of the object receiving
the message.
- Self Message: A message sent by the subject
to himself/herself, that is, to perform
his or her own duties.
|
Description of the elements
of the sequence diagram:
The following is a description
dictionary of the objects in the sequence diagram:
Serial
number |
Object |
Illustrate |
1. |
player1:Player |
The
object of the game, you can start the game and
control the direction of the snake. |
2. |
Timer1:Timer |
Timer
objects that can generate a clock heartbeat
that drives the snake to crawl. |
3. |
map1:Map
|
The
map object, which can be opened, has a food
object and a snake object on it. |
4. |
snake1:Snake |
The
object of the snake, created by the map, can
crawl and can also eat food. |
5. |
Food1:Food |
Food objects, which can be created by maps or
eaten by snakes. |
Note: The model in this paper
is modeled by the modeling tool EA.
|
|
|
UML Diagram Series:
Postscript
I hope you have benefited from reading this.
If you are willing to share your experience, please submit it to us.
If you are interested in our training, consulting and tools:
|