This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

On the cover: I think we have to believe that there is always light,

| last wrote a UML class diagram, specification development will use at ordinary times, or what is written documents, I still need to drawing, like that’s graduation design. I hope I can help you.

Note: The drawing software used in this paper is Microsoft Visio.

An overview,

Sequence diagrams are more of a term for sequential diagrams and sequence diagrams.

Sequence diagram is the object behavior modeling based on interaction. It is a method used by UML to describe the information interaction process between objects and a model to describe the cooperation relationship between objects.

Sequence diagrams are used to capture the chronological interactions between objects in a system run and are composed of lifelines and messages.

The sequence diagram represents the interaction as a two-dimensional diagram. Vertically is the time axis, and time extends down a vertical line. The horizontal axis represents the class primitive roles of individual objects in the collaboration. Class meta-roles are represented by lifelines. When the object exists, the role is represented by a dotted line, and when the object’s process is active, the lifeline is a two-trace line. Messages are represented by arrows from one object’s lifeline to another. Arrows are arranged chronologically from top to bottom in the figure.

Two, constituent elements

2.1, role,

This role can be a user, an external system, a machine, and so on.

It is shown in the following figure in Visio software:

2.2 objects and Lifelines

About naming objects:

  1. Object name and the name of the class, such as: dispatcherServlet: dispatcherServlet
  2. Only the class name is displayed, indicating that it is an anonymous object, such as: :DispatcherServlet
  3. Only the object name is displayed, not the class name, for example, dispatcherServlet

Lifeline: Represented in a sequence diagram as a dotted line extending down from the object icon, indicating the time of the object’s existence.

2.3. Activity bar

The dotted line of the lifeline can be used to indicate the beginning and end of an action, usually in small rectangles.

It’s called activation on Visio software.

Note: but I need to emphasize here is not on the lifeline of article activities must be used to represent the implement, the activities of the join yes to perform more visualization, but in various complex sequence diagrams, activity article also can make here is becoming more complex difficult to draw, in this case, the article tend not to use activities.

2.4, message,

What is a message?

In object-oriented analysis and design, the behavior of objects is also referred to as messages, because the interaction of behavior between objects can also be thought of as the sending of messages between objects. Typically, a message is passed when one object invokes an action in another object.

The sequence diagram focuses on the communication between lifelines, which are the messages sent by objects. UML represents messages with an implementation of lifelines with solid arrows between them, each message going from the sending object to the receiving object.

Such as:

Messages are also subdivided into simple messages, synchronous messages, and asynchronous messages.

Simple messages: Represent how control is sent from one object to another, and do not contain details of the control.

Synchronous messages: means blocking and waiting. For example, after A sends A message to B, object A must wait until B returns before continuing. This is the synchronous message.

Asynchronous message: means non-blocking. For example, after A sends A message to B, the following code can be executed without waiting for B’s execution.

Synchronous messages are represented by solid arrows and asynchronous messages by open arrows.

Self-invoking messages:

The return value of the message:

2.5. Interactive Box

UML introduced interaction boxes in sequence diagrams in 2.0. The interaction box is used to address the conditions and ways of interactive execution. It allows logical components to be represented directly in sequence diagrams and is used to define special conditions and child processes for any part of any lifeline by specifying the application area of the condition or child process. There are 13 kinds of combined fragments, and their names and meanings are as follows:

But let’s just pick out a few common ones, but essentially the usage is the same.

2.5.1 Alt (Select fragments)

So basically, we’ve got the if/else in the diagram.

2.5.2, opt

Contains a sequence that may or may not occur;

As long as my score is less than 60, mom will hit me.

Greater than that doesn’t happen.

2.5.3. Loop

The condition of fragment repetition can be indicated in the criticality when the fragment repeats a certain number of times.

2.5.4 Parallel (Par)

So much for the theory, let’s move on to an example.

【 典 型 范 例】

The following diagram Outlines the execution flow of SpringMVC, and our task this time is to translate it into a sequence diagram.

The sequence diagram is as follows:

4. Talk to yourself

Personally, I think drawing is really useful, especially when it comes to designing something by ourselves. After drawing the relevant pictures, we can think much clearer.

If it is a new XDM, I think drawing is better than code to reflect the idea, you can draw before writing, so that their thinking is clearer.

If it’s a programmer, I think drawing is a basic operation.

That’s all for today’s article.

Hello, THIS is blogger Ning Zaichun: homepage

If you encounter doubts in the article, please leave a message or private letter, or add the homepage contact information, will reply as soon as possible.

If you find any problems in the article, please correct them. Thank you very much.

If you feel helpful, to a key three link 👍, 🙇 XDM

Reference:

UML sequence diagram to summarize: www.trufun.net/UML/UMLwend…

Unified Modeling Language (UML) (2nd edition) Tsinghua University Press