Sequence fragments have been introduced by UML 2.0, which makes it quite easy for the creation and maintenance of an accurate sequence diagram. It is represented by a box called a combined fragment, encloses a part of interaction inside a sequence diagram. The type of fragment is shown by a fragment operator. Types of fragments. UMLet is a free, open-source UML tool with a simple user interface: draw UML diagrams fast, build sequence and activity diagrams from plain text, export diagrams to eps, pdf, jpg, svg, and clipboard, share diagrams using Eclipse, and create new, custom UML elements. UMLet runs stand-alone or as Eclipse plug-in on Windows, OS X and Linux.

Create Sequence Diagrams Online

Create sequence diagrams in seconds with GenMyModel, a free uml online tool to draw UML diagrams.

  • Sequence Diagram Examples to get started quickly
  • No install, web-based application
  • Export (UML,PDF,SVG,JPG)

Draw UML Sequence Diagrams Online

Easy and fast

Create

GenMyModel is an UML editor with powerful features for creating UML sequence diagrams, in the web browser. GenMyModel helps you create sequence diagrams with amazing ease, there's no install, no setup and no learning curve to get started.It’s just a matter of drag, drop and connect.

UML compliant

UML Sequence Diagram TutorialCreate Uml Sequence Diagram

At anytime, GenMyModel assists you draw a valid UML sequence diagram by highlighting the UML elements that match an UML-compliant architecture. It saves time when creating UML elements such as lifelines, behaviors, calls, replies, etc.

  • Design easily
  • Share and export
  • Edit all UML properties

UML Sequence Diagram

Diagram

Generate Uml Sequence Diagram From Java Code

Online

Within GenMyModel, you can create your sequence diagram online, share and export images. Everything is handled in your web-browser with an intuitive user interface. The sequence diagrams conform the UML2 standard. You get both a visual representation, called the diagram, and the internal structure of your model in a tree-based representation. It works on Windows, Mac, Linux and the supported browsers are IE, Chrome, Firefox, Safari and Opera.

Unified Modeling Language

A sequence diagram in the Unified Modeling Language (UML) is an interaction diagram that shows how processes operate with one another and in what order. UML sequence diagrams model the flow of logic within your system in a visual manner, enabling you both to document and validate your logic, and are commonly used for both analysis and design purposes. Sequence diagrams are the most popular UML artifact for dynamic modeling, which focuses on identifying the behavior within your system.

The sequence diagram is a construct of a message sequence chart. A sequence diagram shows object interactions arranged in time sequence. It depicts the objects and classes involved in the scenario and the sequence of messages exchanged between the objects needed to carry out the functionality of the scenario. Sequence diagrams are typically associated with use case realizations.

A sequence diagram shows, as parallel vertical lines (lifelines), different processes or objects that live simultaneously, and, as horizontal arrows, the messages exchanged between them, in the order in which they occur. This allows the specification of simple runtime scenarios in a graphical manner.

Sequence diagrams are typically used to model usage scenarios, the logic of methods and the logic of services.

Source: agilemodeling

Create Uml Sequence Diagram

Sequence Diagram Examples

GenMyModel comes with many free examples, clonable in just a click. You can access these designed templates from the dashboard area. The examples contain sequence diagrams but also class diagrams, use case diagrams and activity diagrams.

The Restaurant example designed in GenMyModel


Learn more about how to draw more diagrams in GenMyModel: Flowchart software, BPMN online

Home > Articles > Software Development & Management > UML

  1. Creating and Deleting Participants
Page 1 of 4Next >
Typically, in UML, a sequence diagram captures the behavior of a single scenario. The diagram shows a number of example objects and the messages that are passed between these objects within the use case. This book chapter explains what they're all about, when to use them—plus how to create and delete participants, use loops, conditionals, and the best way to treat synchronous and asynchronous calls.
This chapter is from the book
UML Distilled: A Brief Guide to the Standard Object Modeling Language, 3rd Edition

This chapter is from the book

This chapter is from the book

UML Distilled: A Brief Guide to the Standard Object Modeling Language, 3rd Edition

Interaction diagrams describe how groups of objects collaborate in some behavior. The UML defines several forms of interaction diagram, of which the most common is the sequence diagram.

Typically, a sequence diagram captures the behavior of a single scenario. The diagram shows a number of example objects and the messages that are passed between these objects within the use case.

To begin the discussion, I’ll consider a simple scenario. We have an order and are going to invoke a command on it to calculate its price. To do that, the order needs to look at all the line items on the order and determine their prices, which are based on the pricing rules of the order line’s products. Having done that for all the line items, the order then needs to compute an overall discount, which is based on rules tied to the customer.

Figure 4.1 is a sequence diagram that shows one implementation of that scenario. Sequence diagrams show the interaction by showing each participant with a lifeline that runs vertically down the page and the ordering of messages by reading down the page.

Figure 4.1. A sequence diagram for centralized control

One of the nice things about a sequence diagram is that I almost don’t have to explain the notation. You can see that an instance of order sends getQuantity and getProduct messages to the order line. You can also see how we show the order invoking a method on itself and how that method sends getDiscountInfo to an instance of customer.

The diagram, however, doesn’t show everything very well. The sequence of messages getQuantity, getProduct, getPricingDetails, and calculateBasePrice needs to be done for each order line on the order, while calculateDiscounts is invoked just once. You can’t tell that from this diagram, although I’ll introduce some more notation to handle that later.

Most of the time, you can think of the participants in an interaction diagram as objects, as indeed they were in UML 1. But in UML 2, their roles are much more complicated, and to explain it all fully is beyond this book. So I use the term participants, a word that isn’t used formally in the UML spec. In UML 1, participants were objects and so their names were underlined, but in UML 2, they should be shown without the underline, as I’ve done here.

In these diagrams, I’ve named the participants using the style anOrder. This works well most of the time. A fuller syntax is name : Class, where both the name and the class are optional, but you must keep the colon if you use the class. (Figure 4.4, shown on page 58, uses this style.)

Each lifeline has an activation bar that shows when the participant is active in the interaction. This corresponds to one of the participant’s methods being on the stack. Activation bars are optional in UML, but I find them extremely valuable in clarifying the behavior. My one exception is when exploring a design during a design session, because they are awkward to draw on whiteboards.

Naming often is useful to correlate participants on the diagram. The call getProduct is shown returning aProduct, which is the same name, and therefore the same participant, as the aProduct that the getPricingDetails call is sent to. Note that I’ve used a return arrow for only this call; I did that to show the correspondance. Some people use returns for all calls, but I prefer to use them only where they add information; otherwise, they simply clutter things. Even in this case, you could probably leave the return out without confusing your reader.

The first message doesn’t have a participant that sent it, as it comes from an undetermined source. It’s called a found message.

For another approach to this scenario, take a look at Figure 4.2. The basic problem is still the same, but the way in which the participants collaborate to implement it is very different. The Order asks each Order Line to calculate its own Price. The Order Line itself further hands off the calculation to the Product; note how we show the passing of a parameter. Similarly, to calculate the discount, the Order invokes a method on the Customer. Because it needs information from the Order to do this, the Customer makes a reentrant call (getBaseValue) to the Order to get the data.

Figure 4.2. A sequence diagram for distributed control

The first thing to note about these two diagrams is how clearly the sequence diagram indicates the differences in how the participants interact. This is the great strength of interaction diagrams. They aren’t good at showing details of algorithms, such as loops and conditional behavior, but they make the calls between participants crystal clear and give a really good picture about which participants are doing which processing.

The second thing to note is the clear difference in styles between the two interactions. Figure 4.1 is centralized control, with one participant pretty much doing all the processing and other participants there to supply data. Figure 4.2 uses distributed control, in which the processing is split among many participants, each one doing a little bit of the algorithm.

Create Uml Sequence Diagram Visio

Both styles have their strengths and weaknesses. Most people, particularly those new to objects, are more used to centralized control. In many ways, it’s simpler, as all the processing is in one place; with distributed control, in contrast, you have the sensation of chasing around the objects, trying to find the program.

Despite this, object bigots like me strongly prefer distributed control. One of the main goals of good design is to localize the effects of change. Data and behavior that accesses that data often change together. So putting the data and the behavior that uses it together in one place is the first rule of object-oriented design.

UML Sequence Diagram - Javatpoint

Furthermore, by distributing control, you create more opportunities for using polymorphism rather than using conditional logic. If the algorithms for product pricing are different for different types of product, the distributed control mechanism allows us to use subclasses of product to handle these variations.

In general the OO style is to use a lot of little objects with a lot of little methods that give us a lot of plug points for overriding and variation. This style is very confusing to people used to long procedures; indeed, this change is the heart of the paradigm shift of object orientation. It’s something that’s very difficult to teach. It seems that the only way to really understand it is to work in an OO environment with strongly distributed control for a while. Many people then say that they get a sudden 'aha' when the style makes sense. At this point, their brains have been rewired, and they start thinking that decentralized control is actually easier.

Creating and Deleting Participants

Sequence diagrams show some extra notation for creating and deleting participants (Figure 4.3). To create a participant, you draw the message arrow directly into the participant box. A message name is optional here if you are using a constructor, but I usually mark it with 'new' in any case. If the participant immediately does something once it’s created, such as the query command, you start an activation right after the participant box.

Figure 4.3. Creation and deletion of participants

Deletion of a participant is indicated by big X. A message arrow going into the X indicates one participant explicitly deleting another; an X at the end of a lifeline shows a participant deleting itself.

In a garbage-collected environment, you don’t delete objects directly, but it’s still worth using the X to indicate when an object is no longer needed and is ready to be collected. It’s also appropriate for close operations, indicating that the object isn’t usable any more.