OOPDA Lab 03B UML SEQUENCE DIAGRAM [using markup]Problem: Develop a Sequence Diagram (“SD”) for a lamp with a pushbutton that will
toggle off and on as user pushes button.
Use at least one ALT or OPT box in your SD. Preferably, more than one, possibly nested!
[Suggestion, consider scenario where user presses button and lamp doesn’t turn on!]
• Behavior to diagram: Imagine a LAMP that has a pushbutton on its base,
which will toggle the lamp ON or OFF.
1) Diagram a typical interaction(s) with a USER, then..
2) Consider one atypical situation and diagram it using
an alternative or an optional grouping
[consider some unusual scenarios,
like pushbutton doesn’t turn on lamp – what to do?]
3) Remember that you can use nested controls; for example, an alt box inside another alt box!
This lab should introduce SD as an analysis tool for a simple(?) problem, plus use of a diagramming app to create SD’s.
There will be about five more SD’s assigned throughout the course, so becoming a little familiar with
sequencediagram.org and its features now will be helpful. Experiment!!
Procedure using seqencediagram.org:
a) Open in browser: https://sequencediagram.org/
b)
– brings up Alice,Bob example with markup at left
c)
[Can click “Help” on menu at upper right then “Instructions” for a short reference manual]
d)
Can edit markup in left panel as needed…
◼ Can erase sample markup, start with your line 1), or edit
◼ continue your markup
◼ Ctrl-z erases last edit
e)[can add controls using mouse and selected objects]
◼
◼
◼
◼
Move mouse pointer and Right-click on diagram to add controls
automatically changes markup.
— select “fragment” for loop, opt, alt or par
— can also add box, note etc.
— click on timeline then “activate” to add active segment to timeline
f) Use “Export” icon at left to save as png
◼ I chose “render” then right-clicked to “save as”. There are several other ways to do this.
g) Drag mouse over your markup code, and paste into a Word doc or a text txt file
2) Deliverable: Submit png of your diagram, plus Word doc with your markup code
Lab03B rev SP23 with markup
p. 1
1/2/2023 2:03 PM
title This is a title
participantspacing equal
#participantspacing gives manual control of spacing between participants, equal: equal distance between all participants, number i.e. 20.5: minimum space
actor “Alice **with a\nlong name” as Alice
#supported participant types: participant, actor, boundary, control, entity, database
participant Server1
database UserData #lightblue
participant Double click to rename
participant Green Participant #lightgreen
#participant “http://sequencediagram.org/corsimg.php?image=phone.png” as phone
#supported: cors images with http/https/file URL
note over Alice,Double click to rename:Messages and notes can be created and edited both by using script to the left\nand interacting directly with the diagram\n\nChange participants of “note over” entries by clicking and dragging its sides
Alice->Double click to rename : Click and drag to create a message, move it by clicking and dragging its middle or start and endpoint\ndouble space makes text smaller
rbox over Alice:Rounded box is created by rbox
abox over Server1:Angular box is created by abox\nit can be placed left of, right of,\nover, and over several participants
box over Alice:Text can be styled using the below syntax:\n**some bold text**\n//some italic text//\n–some small text–\n++some big text++\n\nCombinations:\n++**Big and bold\nlines of text**++\n//–italic and small–//\n\nUse \ to escape wanted */-+ chars\nExamples: c\++ http:\//www.example.org
note left of Green Participant #gray:Color is supported on all\nnotes, participants, and messages
Double click to renameServer1:adding a linear statement
Server1->UserData:makes subsequent messages of the same type
UserData->Double click to rename:linear
linear off
entryspacing 2
parallel
Alice->Server1:The parallel statement simply puts\nall entries at the same y position
Server1>Double click to rename:It is also different from linear since it doesn’t\ndo any intelligent matching for different types\nof entries
parallel off
entryspacing 1
alt right click to create alt, include more entries into the alt by creating them or dragging the alt up
Double click to rename->>Green Participant:Holding ctrl creates an async message
UserDataGreen Participant:info
Double click to renameGreen Participant:info
Double click to rename>Green Participant:info
autonumber off
Double click to renameGreen Participant:info
autonumber
Double click to renameB:info
A->note:info
A->Hospital:info
A->Jenkins:info
A->Actor:info
Messages
• Messages are created by clicking and dragging in the diagram
◦ Hold Shift before clicking for dashed line
◦ Hold Ctrl before clicking for open arrow
◦ Hold Shift+Ctrl before clicking for open arrow with dashed line
• Edit the text of a message by double clicking it
• Change the start and end participants of the message by clicking and dragging the start or
end of the message
• Change position of the message by clicking and dragging the middle of the message
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
7 of 43
https://sequencediagram.org/instructions.html
• Delete the message by clicking it and pressing the delete key
• New line is create using \n
A->B:request
A>B:request
ABob:Test12345
Alice-:2>>Bob:Test
Alice-#00ff00:2>Bob:Test
Alice–#red:4>Bob:Test
AliceBob:Test
AliceBob:Test
AliceBob:Test
AliceBob:Test
https://sequencediagram.org/instructions.html
⎘
Non-instantaneous Messages
• Non-instantaneous messages are created by adding ([delay]) before the target participant,
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
9 of 43
https://sequencediagram.org/instructions.html
examples:
◦ A->(1)B: info
◦ A–>(5)B: info
◦ A->>(2)B: info
• Otherwise non-instantaneous messages behaves just like normal messages
participant A
participant B
participant C
A->(1)B:info
A(1)Server:later message
⎘
Incoming and Outgoing Messages
• Incoming and Outgoing Messages are created by using the special participants [ and ],
examples:
◦ [->A: info
◦ A->]: info
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
10 of 43
[->A:info
B->]:info
https://sequencediagram.org/instructions.html
⎘
Failure Messages
• Failure Messages are created by using x to denot the arrow head, examples:
◦ A-xB: info
◦ A–#redx(1)C: info
A-#redxB:failure 1
C-xB:failure 2
Bx-B:failure 3
C(5)x–A:failure 4
⎘
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
11 of 43
https://sequencediagram.org/instructions.html
Notes and Boxes
• Notes and boxes are created by right clicking in the diagram and selecting the wanted
note / box entry from the menu
• Edit the text of a note or box by double clicking it
• Change the start and end participants of the “note or box over several participants” by
clicking and dragging the start or end of the note or box
• Change position of the note or box by clicking and dragging the middle of the note or box
◦ Note: It is the bottom of the shapes that counts as the y position when dragging
• Delete the note or box by clicking it and pressing the delete key
• New line is create using \n
note over A:note over one\nmultiple lines\nof text
note over A,B:note over several
note left of A:note left of
note right of A:note right of
⎘
⎘
box over A:box over one
box over A,B:box over several
⎘
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
12 of 43
box left of A:box left of
box right of A:box right of
abox left of A:abox left of
abox right of A:abox right of
https://sequencediagram.org/instructions.html
⎘
abox over A:abox over one
abox over A,B:abox over several
⎘
⎘
rbox over A:rbox over one
rbox over A,B:rbox over several
⎘
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
13 of 43
rbox left of A:rbox left of
rbox right of A:rbox right of
https://sequencediagram.org/instructions.html
⎘
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
14 of 43
aboxright over A,B:This is angular boxright
aboxleft over A,B:This is angular boxleft
https://sequencediagram.org/instructions.html
⎘
aboxright over A:This is angular boxright
aboxleft over B:This is angular boxleft
aboxright right of A:This is angular boxright
aboxright left of B:This is angular boxright
aboxleft right of A:This is angular boxright
aboxleft left of B:This is angular boxleft
References
• References are created by right clicking in the diagram selecting over which participants
the reference should be from the menu
• Edit the text of a reference by double clicking it
• Change the start and end participants of the reference by clicking and dragging the start
or end of the reference
• Change position of the reference by clicking and dragging the middle of the note or box
◦ Note: It is the bottom of the shapes that counts as the y position when dragging
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
15 of 43
https://sequencediagram.org/instructions.html
• Delete the reference by clicking it and pressing the delete key
• New line is create using \n
A->B:info
ref over B,C:other interaction
C->D:info
⎘
Dividers
• Dividers are created by right clicking in the diagram and selecting the divider entry from
the menu
• Edit the text of a divider by double clicking it
• Change position of the divider by clicking and dragging it
• Delete the divider by clicking it and pressing the delete key
participant A
participant B
participant C
participant D
==info==
⎘
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
16 of 43
https://sequencediagram.org/instructions.html
Create and Destroy
• Create and destroy are at this point not part of the context menu, participants may be
defined in the start of the diagram
◦ participantNameA->*participantNameB: message: Sends a message to
participantNameB and creates participantNameB
◦ create participantName: Creates the participant without sending a message to it
◦ destroy participantName: Destroys the participant at the previous entry’s y position
◦ destroyafter participantName: Destroys the participant at after a space and gives the
destroy symbol its own space
◦ destroysilent participantName: Destroys the participant at the previous entry’s y
position without rendering the destroy symbol
• Click and drag on the entries to move them in y axis using the mouse
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
17 of 43
participant A
actor X
participant B
https://sequencediagram.org/instructions.html
⎘
A->B:info
B–>*C:
note over C:do something
B*X:message to X
note over X:do something
destroyafter X
A->B:info
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
18 of 43
A->B:info
create C
note over C: C created without message
A>B:request
AD:info
https://sequencediagram.org/instructions.html
⎘
Participant Spacing
• Participant spacing allows control of spacing between the participants
• The participantspacing equal statement makes the spacing between all participants equal
• The participantspacing 50 statement makes the spacing between all participants at least
50
participantspacing equal
participant A
participant B
participant C
⎘
A->B:info info info
Entry Spacing
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
42 of 43
https://sequencediagram.org/instructions.html
• Entry spacing allows control of spacing between the entries
• Click anywhere on the diagram and press the + or – key to change spacing between all
entries
• Add entryspacing statements to change in different places of the diagram
entryspacing 0.1
A->B:info
A->B:info
entryspacing 3
A->B:info
entryspacing 1
A->B:info
A->B:info
⎘
Life Line Style
• Specifies the style of the life lines
◦ lifelinestyle #blue – make all life lines blue
◦ lifelinestyle participantName #red – make participant life line red
◦ lifelinestyle :4 – make all life line weights 4
◦ lifelinestyle C #gray:1:solid – make participant life line gray, line weight 1, solid
1/2/2023, 2:06 PM
SequenceDiagram.org – Instructions and Examples
43 of 43
https://sequencediagram.org/instructions.html
⎘
participant A
participant B
participant C
participant D
lifelinestyle #red:4:solid
lifelinestyle B #black:1:dashed
lifelinestyle C #gray:1:solid
lifelinestyle D ::dashed
A->B:info
B->C:info
C->D:info
Large Example
• Large example including most of the features
Source too large to display
⎘
1/2/2023, 2:06 PM