A sequence diagram is a type of interaction diagram that
shows how processes operate with one another and in what order. It’s a detailed
illustration of a use case, showing the interaction between objects and
components in sequential order.
Key Concepts
- Lifelines:
Represent the objects or participants in the interaction. They are
depicted as vertical dashed lines.
- Messages:
Represent the communication between objects. They are depicted as arrows
between lifelines.
- Activation
Bars: Indicate the period an object is active during the interaction.
- Fragments:
Used for representing complex control structures like loops, conditionals,
and parallel processes.
Sequence Diagram Notation
- Actors:
Represent roles that interact with the system (e.g., user).
- Objects/Lifelines:
Represent instances of classes or components.
- Messages:
Include synchronous (solid arrow with filled head) and asynchronous
messages (solid arrow with open head).
- Return
Messages: Represent responses or return values (dashed arrows).
- Activation
Bars: Vertical rectangles on lifelines indicating the duration an
object is active.
Creating a Sequence Diagram
To create a sequence diagram, follow these steps:
- Identify
the Scenario: Define the specific use case or scenario.
- Identify
Objects: Determine the objects that participate in the scenario.
- Determine
Interactions: Identify the sequence of interactions between objects.
- Layout
Diagram: Place the objects at the top, draw lifelines, and add
messages in sequence.
Example: User Login Sequence Diagram
Scenario: User logs into a system
- Actors:
User
- Objects:
Login Page, Authentication Service, User Database
Steps
- User
requests the login page.
- User
submits login credentials.
- Login
page sends credentials to the Authentication Service.
- Authentication
Service queries the User Database.
- User
Database returns user information.
- Authentication
Service validates credentials and returns success/failure.
- Login
page shows success/failure message to the user.
Sequence Diagram Example
Sequence Diagram Fig 1 |
UML Sequence Diagram Example in PlantUML
Here’s a sequence diagram using PlantUML:
plantuml
@startuml actor User participant
"Login Page" as LoginPage participant
"Authentication Service" as AuthService participant
"User Database" as UserDB User ->
LoginPage : requests login page LoginPage
-> User : displays login form User ->
LoginPage : submits login form LoginPage
-> AuthService : sends credentials AuthService
-> UserDB : queries user info UserDB -->
AuthService : returns user info AuthService
-> AuthService : validates credentials AuthService
--> LoginPage : returns success/failure LoginPage
--> User : displays result @enduml |
Deep Dive into Sequence Diagram Concepts
- Fragments:
- alt:
Represents alternative flows (if-else conditions).
- opt:
Represents an optional fragment (similar to a simple if statement).
- loop:
Represents repeated interaction (looping).
- par:
Represents parallel execution (concurrent operations).
- Synchronous
vs Asynchronous Messages:
- Synchronous:
Sender waits for a response (blocking call). Depicted with a solid arrow
and filled head.
- Asynchronous:
Sender does not wait for a response (non-blocking call). Depicted with a
solid arrow and open head.
- Lifelines
and Activation Bars:
- Lifeline:
Vertical dashed line representing the object's presence over time.
- Activation
Bar: Rectangle on the lifeline representing the time period an object
is active (performing an action).
- Self-Messages:
- A
message sent from an object to itself, representing recursive calls or
self-initiated actions.
Similarly, some other UML Example in PlantUML
A>
UML State Diagram Example in PlantUML
Here’s a state diagram using PlantUML:
plantuml
@startuml 'https://plantuml.com/state-diagram scale 350
width [*] -->
NotShooting state
NotShooting { [*] --> Idle Idle --> Configuring : EvConfig Configuring --> Idle : EvConfig } state
Configuring { [*] --> NewValueSelection NewValueSelection --> NewValuePreview :
EvNewValue NewValuePreview --> NewValueSelection :
EvNewValueRejected NewValuePreview --> NewValueSelection :
EvNewValueSaved state NewValuePreview { State1 -> State2 } } @enduml |
B>
UML Gantt Diagram Example in PlantUML
Here’s a gantt diagram using PlantUML:
plantuml
@startgantt 'https://plantuml.com/gantt-diagram [Prototype
design] lasts 13 days and is colored in Lavender/LightBlue [Test
prototype] lasts 9 days and is colored in Coral/Green and starts 3 days after
[Prototype design]'s end [Write tests]
lasts 5 days and ends at [Prototype design]'s end [Hire tests
writers] lasts 6 days and ends at [Write tests]'s start [Init and
write tests report] is colored in Coral/Green [Init and
write tests report] starts 1 day before [Test prototype]'s start and ends at
[Test prototype]'s end @endgantt |
C>
UML Deployment Diagram Example in
PlantUML
Here’s a deployment diagram using PlantUML:
plantuml
@startuml 'https://plantuml.com/deployment-diagram actor actor actor/
"actor/" agent agent artifact
artifact boundary
boundary card card circle circle cloud cloud collections
collections component
component control
control database
database entity entity file file folder folder frame frame interface
interface label label node node package
package queue queue rectangle
rectangle stack stack storage
storage usecase
usecase usecase/
"usecase/" @enduml example: @startuml 'https://plantuml.com/deployment-diagram actor actor agent agent cloud cloud file file interface
interface actor
-> agent agent ->
cloud cloud ->
file file ->
interface interface
-> cloud @enduml |
D>
UML Mindmap Diagram Example in PlantUML
Here’s a mindmap diagram using PlantUML:
plantuml
@startmindmap 'https://plantuml.com/mindmap-diagram caption
figure 1 title My
super title *
<&flag>Debian **
<&globe>Ubuntu *** Linux
Mint *** Kubuntu *** Lubuntu *** KDE Neon **
<&graph>LMDE **
<&pulse>SolydXK **
<&people>SteamOS **
<&star>Raspbian with a very long name ***
<s>Raspmbc</s> => OSMC ***
<s>Raspyfi</s> => Volumio header My super
header endheader center footer
My super footer legend right Short legend endlegend @endmindmap |
E>
UML Use case Diagram Example in PlantUML
Here’s a use case diagram using PlantUML:
plantuml
@startuml 'https://plantuml.com/use-case-diagram :Main Admin:
as Admin (Use the
application) as (Use) User ->
(Start) User -->
(Use) Admin --->
(Use) note right of
Admin : This is an example. note right of
(Use) A note can
also be on several
lines end note note
"This note is connected\nto several objects." as N2 (Start) .. N2 N2 .. (Use) @enduml |
F>
UML Process Diagram Example in PlantUML
Here’s a process diagram using PlantUML:
plantuml
@startwbs 'https://plantuml.com/wbs-diagram * Business
Process Modelling WBS ** Launch the
project *** Complete
Stakeholder Research *** Initial
Implementation Plan ** Design
phase *** Model of
AsIs Processes Completed **** Model of
AsIs Processes Completed1 **** Model of
AsIs Processes Completed2 *** Measure
AsIs performance metrics *** Identify
Quick Wins ** Complete
innovate phase @endwbs |
G>
UML wireframe Diagram Example in PlantUML
Here’s a wireframe diagram using PlantUML:
plantuml
@startuml 'https://plantuml.com/salt salt { Just plain text [This is my button] ()
Unchecked radio (X) Checked radio []
Unchecked box [X] Checked box "Enter text here " ^This is a droplist^ } @enduml |
H>
UML Component Diagram Example in PlantUML
Here’s a Component diagram using PlantUML:
plantuml
@startuml 'https://plantuml.com/component-diagram package
"Some Group" { HTTP - [First Component] [Another Component] } node
"Other Groups" { FTP - [Second Component] [First Component] --> FTP } cloud { [Example 1] } database
"MySql" { folder "This is my folder" { [Folder 3] } frame "Foo" { [Frame 4] } } [Another
Component] --> [Example 1] [Example 1]
--> [Folder 3] [Folder 3]
--> [Frame 4] @enduml |
I>
UML Class Diagram Example in PlantUML
Here’s a Class diagram using PlantUML:
plantuml
@startuml 'https://plantuml.com/class-diagram abstract
class AbstractList abstract
AbstractCollection interface
List interface
Collection List <|--
AbstractList Collection
<|-- AbstractCollection Collection
<|- List AbstractCollection
<|- AbstractList AbstractList
<|-- ArrayList class
ArrayList { Object[]
elementData size() } enum TimeUnit
{ DAYS HOURS MINUTES } @enduml |
J>
UML Context Diagram Example in PlantUML
Here’s a Context diagram using PlantUML:
plantuml
@startuml !include
https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml '!include
../../plantuml/C4/v2.2.0/C4_Context.puml ' skinparam
linetype polyline ' skinparam
linetype ortho skinparam
nodesep 20 skinparam
ranksep 50 title
"System Context diagram for Display App" System_Ext(Integrator,
"Customer", "Digital") System_Ext(2sg,
"router", "authentication, routing, throttling") System_Ext(sws,
"Web Services\nDisplayService\n(2.1.0)") System(display,
"Display Currency APP", "Framework\n\n/api/display\n") Rel(Integrator,2sg,
"API calls") Rel(2sg,display,
"API calls") Rel(display,sws,
"Downstream WS calls") SHOW_LEGEND() @enduml |
K>
UML Jenkins Diagram Example in PlantUML
Here’s a Jenkins diagram using PlantUML:
plantuml
@startuml !include
<cloudogu/common> !include
<cloudogu/dogus/jenkins> !include
<cloudogu/dogus/cloudogu> !include
<cloudogu/dogus/scm> !include
<cloudogu/dogus/smeagol> !include
<cloudogu/dogus/nexus> !include
<cloudogu/tools/k8s> node
"Cloudogu Ecosystem" <<$cloudogu>> { DOGU_JENKINS(jenkins, Jenkins)
#ffffff DOGU_SCM(scm, SCM-Manager)
#ffffff DOGU_SMEAGOL(smeagol, Smeagol)
#ffffff DOGU_NEXUS(nexus,Nexus) #ffffff } TOOL_K8S(k8s,
Kubernetes) #ffffff actor
developer developer
--> smeagol : "Edit Slides" smeagol ->
scm : Push scm ->
jenkins : Trigger jenkins ->
nexus : Deploy jenkins
--> k8s : Deploy @enduml |
L>
UML Plugin some other API to create icons
diagram using context or container Diagram Example in PlantUML
Here’s a container diagram using PlantUML:
plantuml
Person_Ext(user,
"Clients", "Clients who are using OOO service",
"users") Boundary(new,
"Customer service using CLOVA AiCall") { Boundary(legacy, "Legacy customer
service"){ System_Ext(cc, "Contact
Center", "Contact point, switches customer calls.") Person_Ext(counselor, "Customer
counselors", "Interacts with customers to handle complaints,
process orders, and provide information about OOO service.",
"contact_phone") System_Ext(ars, "ARS",
"Interacts with customers when counselors are not available.") Rel(user, cc, "Makes a call") Rel(cc, counselor, "Connects and
forwards a call to") Rel(cc, ars, "Connects and forwards
a call to") } System(ccai, "CLOVA AiCall",
"Interacts with customers using CLOVA AI tech.") Rel(cc, ccai, "Connects and forwards a
call to") } Person_Ext(manager,
"Manager", "Makes a decision from statistics provided by CLOVA
AiCall", "user_tie") Rel(manager,
ccai, "Retrives statistics from") @enduml |
> UML Math Diagram Example in PlantUML
Here’s a Math diagram using PlantUML:
plantuml
@startuml :<math>int_0^1f(x)dx</math>; :<math>x^2+y_1+z_12^34</math>; note right Try also <math>d/dxf(x)=lim_(h->0)(f(x+h)-f(x))/h</math> <math>P(y|bb"x") or f(bb"x")+epsilon</math> end note @enduml |
M> UML
English Tense Diagram Example in PlantUML
Here’s a English Tense diagram using PlantUML:
plantuml
@startwbs 'https://plantuml.com/wbs-diagram *[#green]
TENSE **[#SkyBlue]
PRESENT \n---\n auxiliary =>[ Do Verb=>do/does\n Be Verb
=>am/is/are\n have=>has/have ]\n model verb=[can, must, may, will,
shall] \n \n Wh=>[When =>time,Where =>place, who/whom
=>person/people, \n why =>reason,what=>object/idea/action,
which=>things] \n Ho=>[How=>manner,How many=>countable, \n How
much=>non countable, How long=>time,How far=>distance] ***
Indefinite ****
Affirmative or Positive \n Rule: sub+ verb-1st+e/es\nsub+[modal verb]
+verb-1st \n [he/she/name/it => s /
es] \nmodel verb=[can, must, may, will, shall] ****
Interrogative \n Rule: Do/Does+sub+ verb-1st ? \n [wh-/Ho-] + [Do/Does]+sub+
verb-1st ? \n [wh-/Ho-] + [modal verb] + sub+ verb-1st ? \n [ I / you / we /
they => Do]\n [he/she/name/it =>Does]\n model verb=[can, must, may,
will, shall] **** Negative
\n Rule: sub+ [do/does]+not + verb-1st\nsub+[modal verb]+[not] +verb-1st \n [
I / you / we / they => do not ]\n [he/she/name/it =>does not] \nmodel
verb=[can, must, may, will, shall] ****
Negative-Interrogative \n Rule: Do/Does+sub+ [not]+ verb-1st ? \n [wh-/Ho-] +
[Do/Does]+sub+[not]+ verb-1st ? \n [wh-/Ho-] + [modal verb] + sub+
[not]+verb-1st ? \n [ I / you / we / they => Do]\n [he/she/name/it
=>Does]\n model verb=[can, must, may, will, shall] ***
Continuous ****
Affirmative or Positive \n Rule: sub+ [am/is/are]+verb-1st+[ing]\n sub+
[modal verb]+[be]+verb-1st+[ing]\n [I => am]\n[he/she/name/it
=>is]\n[you,we,they => are]\nmodel verb=[can, must, may, will, shall] ****
Interrogative \n Rule: [am/is/are]+sub+verb-1st+[ing]?\n[modal
verb]+sub+verb-1st+[ing]? \n [I => am]\n[he/she/name/it
=>is]\n[you,we,they => are] \nmodel verb=[can, must, may, will, shall] **** Negative
\n Rule: sub+ [am/is/are]+[not]+verb-1st+[ing]\n sub+ [modal
verb]+[not]+verb-1st+[ing] \n [I => am]\n[he/she/name/it
=>is]\n[you,we,they => are]\nmodel verb=[can, must, may, will, shall] ***[#blue]
Perfect ****
Affirmative or Positive \n Rule: sub+ [has/have]+verb-3rd \n[he/she/name/it =>has]\n[I/you/we/they
=> have] ****
Interrogative \n Rule: [has/have]+sub+verb-3rd ? \n[he/she/name/it =>has]\n[I/you/we/they
=> have] **** Negative
\n Rule: sub+ [has/have]+[not]+verb-3rd
\n[he/she/name/it =>has]\n[you,we,they => have] *** Perfect
Continuous ****
Affirmative or Positive \n Rule: sub+ [has/have]+[been]+verb-1st+[ing] +obj
+[since/for]+ time \n[he/she/name/it
=>has]\n[I/you/we/they => have] ****
Interrogative \n Rule: [has/have]+sub+[been]+verb-1st+[ing] +obj
+[since/for]+ time ? \n[he/she/name/it =>has]\n[I/you/we/they => have] **** Negative
\n Rule: sub+ [has/have]+[not]+[been]+verb-1st+[ing] +obj +[since/for]+
time \n[he/she/name/it
=>has]\n[I/you/we/they => have] **[#yellow]
PAST \n---\n auxiliary =>[ Do Verb=>did \n Be Verb =>was/were\n
have=>had] \nmodel verb=[should, would, could, might] \n Wh=>[When
=>time,Where =>place, who/whom =>person/people, \n why
=>reason,what=>object/idea/action, which=>things] \n
Ho=>[How=>manner,How many=>countable, \n How much=>non countable,
How long=>time,How far=>distance] ***[#green]
Indefinite ****
Affirmative or Positive \n Rule: sub+ verb-2nd ****
Interrogative \n Rule: Did+sub+ verb-1st ? **** Negative
\n Rule: sub+ [did not]+verb-1st ***
Continuous ****
Affirmative or Positive \n Rule: sub+ [was/were]+verb-1st+[ing]\n sub+ [modal
verb]+[be]+verb-1st+[ing]\n[I/he/she/name/it =>was]\n[you/we/they =>
were] \nmodel verb=[should, would, could, might] ****
Interrogative \n Rule: [was/were]+sub+verb-1st+[ing]? \n[I/he/she/name/it
=>was]\n[you/we/they => were] **** Negative
\n Rule: sub+ [was/were]+[not]+verb-1st+[ing]\n sub+ [modal
verb]+[not]+[be]+verb-1st+[ing] \n[I/he/she/name/it =>was]\n[you/we/they
=> were] \nmodel verb=[should, would, could, might] ***[#blue]
Perfect ****
Affirmative or Positive \n Rule: sub+ [had]+verb-3rd +[before/after] + Past
Indefinite \n[I/he/she/name/it =>had]\n[you/we/they => had] ****
Interrogative \n Rule: [had]+sub+verb-3rd +[before/after] + Past
Indefinite? \n[I/he/she/name/it
=>had]\n[you/we/they => had] **** Negative
\n Rule: sub+ [had]+[not]+verb-3rd +[before/after] + Past Indefinite \n[I/he/she/name/it =>had]\n[you,we,they
=> had] *** Perfect
Continuous ****
Affirmative or Positive \n Rule: sub+ [had]+[bean]+verb-1st+[ing]
+[before/after] + Past Indefinite
\n[I/he/she/name/it =>had]\n[you/we/they => had] ****
Interrogative \n Rule: [had]+sub+[bean]+verb-1st+[ing] +[before/after] + Past
Indefinite? \n[I/he/she/name/it
=>had]\n[you/we/they => had] **** Negative
\n Rule: sub+ [had]+[not]+[bean]+verb-1st+[ing] +[before/after] + Past Indefinite
\n[I/he/she/name/it =>had]\n[you,we,they => had] **[#pink]
FUTURE \n---\n will/shall \n \n
Wh=>[When =>time,Where =>place, who/whom =>person/people, \n why
=>reason,what=>object/idea/action, which=>things] \n
Ho=>[How=>manner,How many=>countable, \n How much=>non countable,
How long=>time,How far=>distance] ***
Indefinite ****
Affirmative or Positive \n Rule: sub+[shall/will]+ verb-1st \n [ I / we =>
shall]\n [you/he/she/name/it/they => will] ****
Interrogative \n Rule: [shall/will]+sub+ verb-1st ? \n [ I / we =>
shall]\n [you/he/she/name/it/they => will] **** Negative
\n Rule: sub+ [shall/will]+not + verb-1st \n [ I / we => shall]\n
[you/he/she/name/it/they => will] ***
Continuous ****
Affirmative or Positive \n Rule: sub+[shall/will]+ [be]+ verb-1st +[ing]\n [
I / we => shall]\n [you/he/she/name/it/they => will] ****
Interrogative \n Rule: [shall/will]+sub+ [be]+verb-1st +[ing] ? \n [ I / we
=> shall]\n [you/he/she/name/it/they => will] **** Negative
\n Rule: sub+ [shall/will]+[be]+[not] + verb-1st +[ing] \n [ I / we =>
shall]\n [you/he/she/name/it/they => will] ***[#blue]
Perfect ****
Affirmative or Positive \n Rule: sub+ [shall/will]+[have]+verb-3rd \n [ I / we => shall]\n
[you/he/she/name/it/they => will] ****
Interrogative \n Rule: [shall/will]+sub+[have]+verb-3rd ? \n [ I / we => shall]\n
[you/he/she/name/it/they => will] **** Negative
\n Rule: sub+ [shall/will]+[not]+[have]+verb-3rd \n [ I / we => shall]\n
[you/he/she/name/it/they => will] *** Perfect
Continuous ****
Affirmative or Positive \n Rule: sub+ [shall/will]+[have been]+verb-1st+[ing]
+obj +[since/for]+ time
\n[he/she/name/it =>has]\n[I/you/we/they => have] ****
Interrogative \n Rule: [shall/will]+sub+[have been]+verb-1st+[ing] +obj
+[since/for]+ time ? \n[he/she/name/it =>has]\n[I/you/we/they => have] **** Negative
\n Rule: sub+ [shall/will]+[not]+[have been]+verb-1st+[ing] +obj
+[since/for]+ time \n[he/she/name/it
=>has]\n[I/you/we/they => have] @endwbs |
Conclusion
Sequence diagrams provide a detailed and structured way to
visualize and document the flow of a system's interactions. They help in
understanding the dynamic behavior of a system and are essential in the design
and analysis phases of software development. By mastering sequence diagrams,
you can better communicate and document how your system operates and interacts
with various components and external entities.
Plugin plantuml or using an online editor to create your flows diagram
For Online
Use:
http://www.plantuml.com/plantuml/uml/SyfFKj2rKt3CoKnELR1Io4ZDoSa70000
https://plantuml.com/ascii-math
For Plugin:
goto IntelliJ or eclipse software update search plantuml and install
0 Comments