note Sequence diagram
Sequence Diagram, also called sequence diagram or sequential diagram, is a UML behavior diagram. It displays dynamic collaboration among multiple objects by describing the time sequence of sending messages between objects. It can represent the sequence of use case behavior. When a use case behavior is executed, each message in the sequence diagram corresponds to a class operation or trigger event in the state machine that causes the transition. via: wiki
brief introduction
Sequence diagram definition: describes the time sequence of messages transmitted between objects. It is used to represent the behavior sequence in use cases. It is an interaction diagram that emphasizes the time sequence of messages
Things described by the sequence diagram: the sequence diagram describes the interactions between classes in the system, and models these interactions as message exchanges. The sequence diagram describes the classes and the messages of the expected behavior to complete the exchange between classes. Each message in the sequence diagram represents an operation of the class or a trigger event that causes the change of the state machine
Time sequence diagram representation: the objects participating in the interaction are arranged horizontally at the top of the time sequence diagram, and a vertical dotted line is drawn at the bottom of each object. Object A sends messages to object B, which is represented by a solid line with an arrow. The solid line starts from the dotted line at the bottom of object A and ends at the dotted line at the bottom of object B; The solid arrows are placed horizontally, and the closer they are to the top, the earlier they are sent
Sequence diagram track: the sequence diagram provides a clear visual track over time
Sequence Diagram Elements
The modeling elements included in the sequence diagram mainly include: object, lifeline, activation, message, etc
object
Object: The object in the sequence diagram plays a role in the interaction
Object symbol: objects in the sequence diagram are represented in the same way as objects in the object diagram. The object name is contained in a rectangle and underlined
Object creation timing: objects can be created at the beginning of interaction or during interaction
- At the top: if the object is at the top of the sequence diagram, it means that the object already exists at the beginning of the interaction
- Not on top: if the object's position is not on top, the object is created during interaction
lifeline
Lifeline: A lifeline is a vertical dotted line, which indicates the existence of objects. In the sequence diagram, there is a lifeline at the bottom of each object
Lifeline function: Lifeline is a timeline, which exists from the top to the bottom of the sequence diagram, and its length depends on the interaction time
Lifeline of objects: objects and lifelines together are the lifelines of objects. This concept includes object icons and lifeline icons below objects
activation
Activation: represents the period when an object in the sequence diagram executes an operation. The activation period can be understood as the content in {} in semantics, indicating that the object is occupied to complete a task
Deactivation: refers to that the object is idle and waiting for a message to activate it
Activation representation: when the object is in the activation period, the lifeline can be widened to a rectangle, and this rectangular bar becomes the activation bar
Time for activation and deactivation:
- Activate: Object activation is activated at the top of the activation bar
- Deactivation: Deactivation at the bottom of the activation bar usually occurs when a message leaves the object lifeline
news
Message concept: defines the class of information exchange in interaction and collaboration, and models the communication content between objects
Message action:
- Action type: messages allow to transfer information (transfer parameters) between entities, allow entities to request other services, and communicate between objects by sending and receiving messages;
- Results: messages can trigger operations, raise signals, or make target objects created or destroyed
Asynchronous and synchronous communication of messages:
- Asynchronous communication: when a message is a signal, wait for the other party to trigger the corresponding method after sending the signal. This is an asynchronous communication between explicitly named objects
- Synchronous communication: directly call the method of the object and execute the method to return the result. This operation with return control mechanism is synchronous communication
Difference between messages in sequence diagram and collaboration diagram: messages in sequence diagram emphasize order, and messages in collaboration diagram emphasize relationship between objects exchanging messages
reference resources
www.ibm.com/developerworks/cn/rational/rationaledge/content/feb05/bell/3101.html
blog.csdn.net/shulianghan/article/details/17927131
design-patterns.readthedocs.org/zh_CN/latest/read_uml.html
This article is written by Chakhsu Lau Creation, adoption Knowledge Sharing Attribution 4.0 International License Agreement.
All articles on this website are original or translated by this website, except for the reprint/source. Please sign your name before reprinting.