UML 2.0 - Sequence Diagram, Interaction Fragments

Summary

Sequence diagrams are one of the most widely used behavioural modeling UML diagrams. They are intuitive to use and understand and require less time from the user to become proficient than using the semantically equivalent collaboration diagram (now called communication diagrams in UML2). However, sequence diagram have limitations when required to model more complex system behaviour, such as conditional behavior and iteration (see multiple statement article).

This article provides an overview of the interaction fragment notation introduced in UML2 and illustrates how this can be used to overcome the shortcomings of the sequence diagram notation in UML1.x.

Sequence Diagrams

Sequence diagrams are one of the most useful UML diagrams for modelling dynamic interaction within systems. One of their main strengths is the simplicity of notation used, however this can also be viewed as a drawback when attempting to model behaviour such as iteration and conditional.

Another drawback is the fact that sequence diagrams quickly become large and unwieldy when modelling slightly more complex system behaviour. One answer is to use collaboration diagrams (known as communication diagrams in UML2), however, these are typically less easy to master than the semantically equivalent sequence diagram.

Consider the case where conditional behaviour needs to be modelled. In the following example we want to model how a system treats different types of inbound messages. The following is the set of steps performed as our system receives the messages from an external system:

The following sequence diagram shows how we might model this using UML1.x. Due to the lack of formal notation it is difficult to model the case where message validation fails or to show the different processing requirements for each message type. The best we can do is to add anchor notes where the variation in message processing and invalid message take place.

This is not a satisfactory solution as it requires the user to collate multiple sequence diagrams to gain a full picture of how the system performs message processing. A better approach is to use UML2.0 notation and incorporate interaction fragments in the sequence diagram.

UML 2.0 Interaction Fragments

UML 2.0 has extended the sequence diagram notation to overcome the aforementioned issues with the introduction of interaction fragments. An interaction fragment encloses a group of messages that are associated with a specific type of processing construct, such as iteration or conditional operations. They can also be used as reference links to other sequence diagrams thereby eliminating the need for anchor notes.

The following diagram shows an example of a conditional interaction fragment. In this instance the Game object determines the winner and chooses the correct message to display depending on each player’s individual score. This fragment has the logical name Winner and is identified as a conditional fragment by the ‘alt’ label.

Using interaction fragments we can break our original diagram into the relevent processing sections for each message type. As we can see, the diagram contains 2 conditional alternate fragments, with the Process Message alternate fragment embedded within the Good Message fragment. We could go further and add reference fragments within each of the 3 Process message 'lanes' which act as links to other sequence diagrams focusing on specific message processing behaviour..

Using interaction fragments we are now able to show precise detail within one sequence diagram without the need to apply anchor notes or introduce non-standard notation.

Join our mailing list to receive the latest white papers, book reviews and course schedules once a month.





I.T. Professionals at training

Click here to read this month's top 10 tips for improving your Production Chain


Are You Project Optimised?

Simply answer 20 multiple choice questions to find out. Your full report (with rating and advice) will be emailed to you immediately on completion.


TRY IT NOW >>

 

Company News