Sequence with PlantUML

Tram Ho

1. Introduction

  • Sequence diagram is a very important kind of diagram in programming flow description. Usually the tools used to draw sequence diagrams are StartUml, Astah, …. I will introduce to you another tool to draw sequences is PlantUML.

2. Let’s get started!

a. Basic

  • The “->” symbol is used to draw a message between two participants. Participants do not need to be explicitly declared.
  • Use the -> symbol to represent an object’s response message to another object. eg:

Result:

b. Object declaration

If the keyword “participant” is used to declare an object. The order in which objects are declared will be the order in which they are displayed. Using other keywords to declare the audience will change according to the declared keyword:

Result:

You can also rename the declared object with the keyword: as. Change the background color of the object.

Result:

You can use the order keyword to customize the display order of your objects.

result:

You can use double quotes to define the object. And you can use the as keyword to give those objects an alias.

Result:

c. Message to Self

The object can send the message to itself.

Result:

d. Text alignment

You can place the response message’s text below the arrow, using the command skinparam responseMessageBelowArrow true.

Result:

e. Change the arrow style

You can change the arrow style in a number of ways: Add a last x to indicate a lost message Use or / instead of <or> to only have the bottom or upper part of a Repeat arrow arrowhead (for example, head >> or //) for a thin drawing Use – instead – to have a dotted arrow Add the last “o” at the beginning of the arrow Use the two-dimensional arrow < ->

Result:

f. Change arrow color

You can change the color of individual arrows by using symbols.

Result:

Conclusion

Today, I would like to stop here. The next content I would like to share in the next section.

Share the news now

Source : Viblo