Beyond the Basics of Sequence Diagrams: Part 3

We got the final part of this series right here. While we did spend some time discussing Gates and its use or relevance to Sequence Diagrams, we now concentrate on just two elements known as Combined fragments.

Combined fragments (break and parallel)

      If you do recall, back in the post called – The Basics & the Purpose of Sequence Diagrams ~ Part 2–  there was information on combined fragments known as “alternative,” “option,” and “loop.” While these combined fragments are what most people will utilize the most, there are other combined fragments, such as  break and parallel, which a large share of people will find useful.

Break

 

The break combined fragment is similar to the option combined fragment. There are two exceptions, though. First, a break’s frame has a name box stating “break” instead of “option.” Second, when a break combined fragment’s message is to be executed, the enclosing interaction’s remainder messages will not be executed because the sequence breaks out of the enclosing interaction.

Breaks are utilized to model exception handling. The figure below uses a break combination fragment since it treats the balance < amount condition as an exception instead of as an alternative flow. When the sequence gets to the return value “balance,” it checks to see if the balance is less than the amount. If the balance is not less than the amount, the next message sent is the addDebitTransaction message, and the sequence continues as normal. However, in cases where the balance is less than the amount, then the sequence enters the break combination fragment and its messages are sent. Once all the messages in the break combination have been sent, the sequence exits without sending any of the remaining messages (e.g., addDebitTransaction).

An important thing to note about breaks is that they only cause the exiting of an enclosing interaction’s sequence and not necessarily the complete sequence depicted in the diagram. Where there is a break combination, which is part of an alternative or a loop, then only the alternative or loop is exited.

Parallel

 

When the processing time needed to finish portions of a complex task takes longer than previously thought, some systems handle parts of the processing in tandem. The parallel combination fragment element should be used when creating a sequence diagram that shows parallel processing activities.

The parallel combination fragment is drawn using a frame, and you place the text “par” in the frame’s namebox. You then break up the frame’s content section into horizontal operands separated by a dashed line. Each operand in the frame represents a thread of execution done in parallel.

While the figure below may not illustrate the best computer system example of an object doing activities in parallel, it offers an easy-to-understand example of a sequence with parallel activities. The sequence goes like this: A hungryPerson sends the cookFood message to the oven object. When the oven object receives that message, it sends two messages to itself at the same time (nukeFood and rotateFood). After both of these messages are done, the hungryPerson object is returned yummyFood from the oven object.

All things considered, remember that the sequence diagram is a versatile diagram that can be used to document a system’s needs and to flush out a system’s design. The reason the sequence diagram is so useful is because it shows the interaction logic between the objects in the system in the time order that the interactions take place. We, of course, explained all this from the very first post we put out in the first series we did on these diagrams - The Basics & the Purpose of Sequence Diagrams ~ Part 1. We really do hope you found this series useful. Moreover, we would like to invite you to let us in on any new topics you would like us to tackle.

Posted via email from Creately | Comment »

Beyond the Basics of Sequence Diagrams - Part 2

We wrap up the week with where we left off with Sequence Diagrams and a look into more advanced elements. Today we will concentrate on the use of Gates in Sequence Diagrams.

Gates

The previous post illustrated how to reference another sequence diagram via sending across data through parameters and also return values. Yet, there’s another way to send across data between two sequence diagrams. Gates could be regarded as being a simple way to model the passing of data between a sequence diagram and its context. A gate is a message that is highlighted with one end connected to the sequence diagram’s frame’s edge and the other end connected to a lifeline. A reworking of Figure 1  (from Part 1 of this series) using gates can be seen in the following diagram.

 

Figure 2 (from Part 1 of this series) with the utilization of gates would look like what is shown below.

 

Figure 2 has an entry gate called getBalance that takes the parameter of accountNumber. The getBalance message is an entry gate, because it is the arrowed line that is linked to the diagram’s frame with the arrowhead linked to a lifeline. The sequence diagram has an exit gate, which returns the balance variable. The exit gate is known, because it’s a return message that is connected from a lifeline to the diagram’s frame with the arrowhead connected to the frame.

The real purpose behind these recent posts on Sequence Diagrams have been to offer anyone, irrespective of their experience in UML, with an effective  ”crash course” in understanding this area. We think this aim has been achieved. After this series is over (stay tuned for Part 3 next week!), we hope to bring more interesting insights into UML during the coming weeks and months. Till then, Happy Diagramming!

 

Posted via email from Creately | Comment »