A sequence diagram is a view that describes the order in which information is passed between the object itself and the object. It is used to represent the order of behavior in a use case. When performing a routine, each message in the sequence diagram corresponds to a class operation or trigger event that causes a transition in the state machine. It highlights the order in which the interacting objects and messages are exchanged.
The sequence diagram consists of 4 markers: Object, lifeline, message, and activation.
A two-dimensional diagram is used to describe the interaction between objects in a system, in which the longitudinal axis is the time axis, and the time is extended along the vertical line, and the horizontal axis represents the interacting object. When an object is present, the lifeline is represented by a dashed line, and when the object's process is active, the lifeline is a double. The message is represented by an arrow from one object to another object lifeline. The arrows are arranged in chronological order from top to bottom in the diagram.
object:
An object is a collection of specific behaviors and properties.
There are three ways to represent objects:
1. Include the object name and the class name,
Such as:
2. Only the class name.
Such as:
3. Only object names
Such as:
Lifeline:
Lifelines are used to describe the existence period of an object, and the dashed line underneath the object is the lifeline of the object.
Such as:
activation:
The control focus is the period of time that the active person or object is in the execution state.
Such as:
message:
Messages are used to describe how and what the objects interact with each other.
There are four types of messages: synchronous messages, asynchronous messages, return messages, self-correlating messages
1. Synchronous message: Once an object is issued a synchronization message to another object, it will be in a blocking state until the other object responds.
Presentation mode:
2. Asynchronous message: After an object sends an asynchronous message to another object, the object can do other things without waiting for the response of another object.
Presentation mode:
3. Return message: The return message of the synchronization message
Presentation mode:
4. Self-correlating message: Used to describe the mutual invocation of an object's intrinsic functions.
Presentation mode:
Finally, we need to explain the module for Process control in the sequence diagram: Compound fragment (Combined fragments)
There are a number of complex fragments, here are some of the main introduction:
Conditional judgment, optional, loop, sync
1. Conditional judgment: Used to describe the code in If...else ... This structure
Mark as "Alt"
For example:
2. Optional: is a special "conditional judgment", it is just an if, no else if or else
The optional tags are: opt
For example:
3. Loop: Refers to a statement block in the code for, while, and so on.
The loop is marked as: loop
For example: [M,n] in the image below is the execution of at least m times, up to N times
4. Synchronization: Used to describe the situation of multithreading.
The tags that are synchronized are: par
For example:
steps to draw a sequence diagram:
1. Determine the scope of the interaction
2. Identify the actors and objects involved in the interaction
3. Determine the life cycle of the active person, the object
4. Identify the messages generated in the interaction
5. Refine the content of the message