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

Example Analysis of message and constraint Concepts in UML sequence Diagram

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

Share

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

Editor to share with you the UML sequence diagram of the concept of messages and constraints of the example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!

Message

For readability, the messages of a UML sequence diagram always start at the top and are generally located on the left side of the diagram. Then the secondary message is added to the diagram, slightly lower than the previous message.

To show that an object (for example, a lifeline) passes a message to another object, you draw a line pointing to the receiving object, including a solid arrow (if it is a synchronous invoke operation) or a stick arrow (if it is an asynchronous signal). The message / method name is placed above the line with an arrow. The message being passed to the receiving object represents an operation / method implemented by the receiving object's class. In the example in figure 4, the analyst object invokes the system object of an instance of the ReportingSystem class. The analyst object is calling the getAvailableReports method of the system object. The system object then calls the getSecurityClearance method on the secSystem object, including the parameter userId, whose class type is SecuritySystem. two

Figure 4: an example of passing messages between objects

In addition to showing only the message calls on the UML sequence diagram, the figure in figure 4 also includes the return message. These return messages are optional; a return message is drawn as a dotted line with an open arrow pointing back to the lifeline of the source on which you place the return value of the operation. In figure 4, when the getSecurityClearance method is called, the secSystem object returns userClearance to the system object. When the getAvailableReports method is called, the system object returns availableReports.

In addition, the return message is an optional part of the UML sequence diagram. The use of the return message depends on the level of concrete / abstraction of the modeling. If better materialization is needed, it is useful to return a message; otherwise, an active message is sufficient. I personally like to include a return message whenever a value is returned, because I find that extra details make a UML sequence diagram easier to read.

When UML sequence diagrams are modeled, sometimes an object will need to pass a message to itself. When does an object call itself? A purist would argue that an object should never pass a message to itself. However, modeling a message to its own object can be useful in some situations. For example, figure 5 is an improved version of figure 4. The figure 5 version shows the system object that calls its determineAvailableReports method. By expressing that the system passes the message "determineAvailableReports" to itself, the model focuses on the fact of the process rather than on the system object.

To draw an object that invokes itself, as you usually do, draw a message, but instead of connecting it to another object, you connect the message back to the object itself.

Figure 5: the system object calls its determineAvailableReports method

The message example in figure 5 shows synchronous messages; however, in the UML sequence diagram, you can also model asynchronous messages. An asynchronous message is similar to a synchronous representation, but the message is drawn with a stick-shaped spearhead, as shown in figure 6.

Figure 6: UML sequence picture segment representing an asynchronous message delivered to entity 2

Constraint

When modeling the interaction of an object, sometimes a condition must be met before the message is delivered to the object. Constraints are found throughout the UML diagram to control the flow. Here, I will discuss the constraints of both UML1.x and UML2.0. In UML1.x, a constraint can only be assigned to a single message. In UML1.x, to draw a constraint on a UML sequence diagram, you place the constraint element on the message line of the constraint, before the name of the message. Figure 7 shows a fragment of the UML sequence diagram with a constraint on the message addStudent method.

A fragment of a 7:UML1.xUML sequence diagram in which the addStudent message has a constraint.

In figure 7, the constraint is the text "[pastDueBalance=0]". With the constraint on this message, if the accounts receivable system returns a zero overdue balance, the addStudent message will be delivered. The symbol of the constraint is simple; the format is:

[BooleanTest]

For example

[pastDueBalance=0]

Combined fragments (variants, selections, and loops)

However, in most UML sequence diagrams, the UML1.x "in-line" constraint is not sufficient to handle the necessary logic for a modeling sequence. This lack of functionality is a problem with UML1.x. UML2 has solved this problem by removing the "in-line" constraint and adding a symbol element called combinatorial fragmentation. A composite fragment is used to group a set of messages together to display conditional branches in an UML sequence diagram. The UML2 specification specifies 11 types of interaction for composite fragments.

These are all the contents of the article "sample Analysis of message and constraint Concepts in UML sequence diagrams". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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