Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are symbols and lifelines in UML sequence diagrams

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what are the symbols and lifelines in the UML sequence diagram". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "what are the symbols and lifelines in the UML sequence diagram"?

The purpose of UML sequence diagrams

UML sequence diagrams are mainly used to show the interactions between objects in the order in which they occur. Much like class diagrams, developers generally think that UML sequence diagrams only make sense to them. However, business people in an organization may find that UML sequence diagrams show how different business objects interact and are useful for communicating how the current business is going. In addition to recording the current events of the organization, a business-level UML sequence diagram can be used as a requirements document to deliver requirements for a future system. During the requirements phase of the project, analysts can take use cases to the next level by providing a more formal level of expression. In that case, use cases are often refined into one or more UML sequence diagrams.

The technical staff of the organization can find that UML sequence diagrams are very useful in recording how the behavior of a future system should behave. In the design phase, architects and developers can use diagrams to mine the interactions between system objects, thus enriching the entire system design.

One of the main uses of UML sequence diagrams is to transform the requirements expressed by use cases into a further, more formal level of fine expression. Use cases are often refined into one or more UML sequence diagrams. In addition to their use in designing new systems, UML sequence diagrams can also be used to record how objects that exist in the system (called "legacy") now interact. This document is useful when handing over the system to another person or organization.

Symbol

Since this is part of my UML2-based series of articles on UML diagrams, we need to first discuss a supplement to UML2 graph symbols, a symbolic element called a frame. In UML2, frame elements are used as a basis for many other graphic elements, but most people come into contact with frame elements for many times as graphical boundaries of the graph. When providing a graphical boundary for a diagram, a frame element provides a consistent location for the label of the diagram. The frame components are optional in the UML diagram; as you can see in figures 1 and 2, the label of the diagram is placed in the upper left corner, in the "namebox" of the frame I will call, a curl rectangle, and the actual UML diagram is defined inside the larger closed rectangle.

Figure 1: empty UML2 frame components

In addition to providing a graphical border, the frame elements used in the diagram also have important functions to describe interactions, such as UML sequence diagrams. A sequence on a UML sequence diagram receives and sends messages (also called interactions), which can be modeled by connecting messages to the boundaries of frame elements (as seen in figure 2). This will be described in more detail in later paragraphs on "beyond the basics".

Figure 2: a UML sequence diagram for receiving and sending messages

Notice in figure 2 that for UML sequence diagrams, the label of the diagram starts with the word "sd". When you use a frame element to close a diagram, the label of the diagram needs to be in the following format:

Diagram type graph name

The UML specification provides specific text values for graph types. (for example, sd stands for UML sequence diagram, activity for activity diagram, and usecase for use case diagram).

Basics

The main purpose of UML sequence diagrams is to define the sequence of events and produce some desired output. The point is not the messages themselves, but the order in which they are generated; however, most UML sequence diagrams represent what messages are passed between objects in a system, and the order in which they occur. The figure conveys information in horizontal and vertical dimensions: the vertical dimension represents the time series of the message / call from top to bottom, and the horizontal dimension represents the object instance to which the message is sent from left to right.

Lifeline

When drawing a UML sequence diagram, place lifeline symbol elements across the top of the diagram. The lifeline represents the role or object instance modeled in the sequence. 1 Lifeline draws a square, a dotted line from the top down, through the center of the bottom boundary (figure 3). The lifeline name is placed in the box.

Figure 3: an example of a Student class for a lifeline of an entity named freshman

The lifeline naming standard of UML is in the following format:

Entity name: class name

In the example shown in figure 3, the lifeline represents the entity of class Student, whose entity name is freshman. Note here that the lifeline name is underlined. When underscores are used, it means that the lifelines in the UML sequence diagram represent specific entities of a class, not specific kinds of entities (for example, roles). In a future article, we will learn about structured modeling. For now, just review the UML sequence diagram, which may include roles (such as buyer and seller) without describing who plays those roles (such as Bill and Fred). This allows the reuse of pictures in different contexts. Simply drag and drop, the instance name of the UML sequence diagram is underlined, but the role name is not.

Our lifeline example in figure 3 is a named object, but not all lifelines represent named objects. Instead, a lifeline can be used to represent an anonymous or unnamed entity. When modeling an unnamed instance on a UML sequence diagram, the lifeline name follows the same pattern as a named instance; but the location of the lifeline name is left blank instead of providing an example diagram name. Referring to figure 3 again, if the lifeline is representing an anonymous example diagram of the Student class, the lifeline would be: "Student". At the same time, because UML sequence diagrams are used in the project design phase, one unspecified object is perfectly legal: for example, "freshman".

At this point, I believe you have a deeper understanding of "what are the symbols and lifelines in the UML sequence diagram". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report