The fourth chapter of the UML Essence sequence diagram

Source: Internet
Author: User
Tags switch case

Fourth Chapter sequence diagram
In general, we will draw a sequence diagram of the relevant behavior of a plot, the graph will show the use case (using cases) may appear in some of the objects, as well as the transfer of information between objects. This chapter will be a simple plot to do all aspects of the sequence diagram of the relevant discussion. Suppose we now have an order and are ready to invoke one of its commands to figure out the price of the order. In order to achieve this, the order needs to look at some of the order details in it and determine their price, and the price is determined based on the pricing rules of the products included in the order details. After all the order details have been done, the order is then calculated as the entire discount, which is based on the rules tied to the customer. is a way of realizing this plot. The way the timing drawing interacts is to have a lifeline for each participant, and the information is executed sequentially from the top of the page, and the order of the messages is viewed down the page. Description: For the participants in the diagram, they can be linked by simply looking at some naming methods. , we can see that the getproduct call will return aproduct, which is the same as the aproduct name of the destination getprocingdetails the next call, so the two are worth the same participant.Please note that I only mention this call to draw the return message arrow; The reason for this is to show the correlation between the two calls.
The good thing about a time series diagram is that I hardly have to explain the notation, and everyone can understand it.
is another way of realizing this plot. He solved the same problem, but the participants worked together and the way they solved the problem was very different. Order requires each order line to calculate its own price. And order line goes a step further by handing the calculation to product; Note that a parameter is passed to product at this time. Similarly, in order to calculate a discount, order will also call a method of customer. Because the customer needs to get some information from order when doing this, it does a call to order (Getbasevalue) and has obtained the necessary information.
The comparison between the two: we can clearly see that the two interactive situations adopt different design styles. The first diagram uses a centralized control design style, which allows a participant to be responsible for most of the work in the entire process, while the other participants are only responsible for providing the information. The second figure uses a decentralized control style, which disperses the process to many participants, each of whom is responsible for a small portion of the work performed in the calculation.
Most of the novice object-oriented programming, more commonly used centralized control of the design style. In many ways, this is relatively straightforward, as all processes are done in the same place, and on the other hand, if we adopt a decentralized control design style, there is a sense of how the tracking program will go around between objects (PS: No one else's code is how to write, I was drunk)。
To achieve better design results, one of our main design goals is to limit the possible impact of changes to a small area. Data and access to this data is usually followed by changes, so it is the first principle of object-oriented design to put the data in the same place as the behavior that uses it.
Commentary: Separating a piece of work gives us the opportunity to cope with changing needs at different points of variability. However, it has to pay a lot of costs. Therefore, the concept of our object-based process design has a simple structure that slowly shifts to pre-generated complex structures to cope with the potential future changes in demand. Later on, it is transformed into a simple structure that evolves into the necessary complex structures as the requirements evolve.
1, the participation object is generated in the deletion actionThere are some additional representations in the timing diagram that can show the result of a participating object in the delete action (see below). In order to produce a participating object, we will direct the information arrows directly to the rectangle of the participating objects, and if the participants do something immediately after they are created, you can start the active bar immediately below the object rectangle. In a garbage collection environment, we do not delete objects directly, but you can still use the X tag to indicate that the object is no longer needed, please recycle it. It is also appropriate to add an X mark to some end operation, because it represents that the object is no longer available.
2. Interactive frame such as loop and conditional mode logicA common topic in time series diagrams is how to draw loops and conditional behaviors. What we want to explain is that the timing diagram is not good at doing this. If you want to draw this type of control structure, it is best to use the activity diagram, even the program code itself.
Commonly used interactive box operators:
Arithmetic Sub Significance
Alt (multiple selection) One executes it in multiple fragments, and the one in which the condition is true is executed.
Commentary: Alt equals If...then. else.. endif or switch case
opt (optional) You can choose a fragment that you want to execute, and it will be executed only if it is set to true. It is equivalent to an ALT interaction box with only one time instance sequence.
Commentary: Opt equals if...endif
Par (parallel) Several fragments that can be executed in parallel
Commentary: The order of execution between different fragments is not very important. However, the information in the same fragment should be executed according to the timeline.
Loop (looping) This fragment may be executed several times, and the condition of its establishment is the basis of whether the counter is to be executed.
Commentary: Generally in loops, we use the break operator to jump out of the normal execution of the loop.
Critical (critical area) Within this fragment, only one execution (thread) can execute it at a time
Neg (negative) Represents an invalid interaction situation shown in this fragment.
Commentary: A more net-relative operation is an assert (assumption) that represents the only effective interaction scenario shown in this fragment. In addition, we can use the Ignore (ignore) operator to explain that the interactive box will think that this information is unimportant, so ignore them (directly do not draw it out), or you can use the consider (emphasis) operator to explain that the interactive box that only this information is important, and therefore will show them.
Ref (Reference) Used to point to an interactive situation as defined in another diagram. We'll make it a box that covers the lifeline of the contact in the interactive situation.
Commentary: The syntax of ref is
Interaction Case Name (parameter string): return value

3, synchronous and non-synchronous calls to version UML2, these small differences are very important. Because in version UML2, filled arrows represent synchronous messages (synchronous message), and hollow, bar-shaped arrows represent non-synchronous messages (asynchronous message)
4. When to use time series diagrams to know the behavior of several objects in a use case, use a timing diagram. Timing is a great way to show the cooperation between objects, which is not suitable for the precise definition of object behavior. You can use a state diagram if you want to understand the behavior of an object between different use cases. If you want to know the behavior across multiple use cases or actors

The fourth chapter of the UML Essence sequence diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.