66
2IW80 Software specification and architecture Interaction diagrams Alexander Serebrenik

Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

2IW80 Software specification and architecture

Interaction diagrams

Alexander Serebrenik

Page 2: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Before we start

True or False? a)  Provided interface is represented by b)  Provided interface is represented by c)  Manifestation maps artifacts to nodes

Page 3: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Before we start

True or False? a)  Provided interface is represented by b)  Provided interface is represented by c)  Manifestation maps artifacts to nodes

True

True

False Manifestation maps artifacts to use cases / classes / components / packages, relation between artifacts and nodes is called deployment

Page 4: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Before we start

/ SET / W&I PAGE 4 26/02/15

True or False? a)  Provided interface is represented by b)  Provided interface is represented by c)  Manifestation maps artifacts to nodes d)  b::C is accessible in h e)  b::D is accessible in h

h

e a

C

F

b

F

C

D <<access>>

<<import>> G <<import>>

Page 5: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Before we start

/ SET / W&I PAGE 5 26/02/15

True or False? a)  Provided interface is represented by b)  Provided interface is represented by c)  Manifestation maps artifacts to nodes d)  b::C is accessible in h e)  b::D is accessible in h

h

e a

C

F

b

F

C

D <<access>>

<<import>> G <<import>>

Yes

No

Page 6: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

This week sources

Slides by

David Meredith, Aalborg University, DK

Marie-Elise Kontro, Tampere University, FI

Site by

Kirill Fakhroutdinov GE Healthcare, USA

Page 7: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Missing link

•  Use case diagram describes tasks that system must help actors to perform

•  Class diagram describes classes required to realize use cases and relationships between these classes

•  Interaction diagrams describe how objects interact to realize the use case scenarios

•  Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams

/ SET / W&I PAGE 7 26/02/15

Page 8: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Interaction diagrams

/ SET / W&I PAGE 8 26/02/15

Sequence Diagram

Timing Diagrams

Interaction Overview Diagram

Communication Diagram

Page 9: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

•  The most common kind of Interaction Diagrams •  shows how actors and objects interact to realize a use case

scenario •  focuses on the Message interchange between a number of

Lifelines

•  You draw a sequence diagram if, e.g.: •  you have a use case diagram, to describe how the main

components of the system interact •  you have identified messages arriving at an interface of a

component, to describe how the internal parts of the component interact.

Page 10: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

•  The most common kind of Interaction Diagrams •  shows how actors and objects interact to realize a use case

scenario •  focuses on the Message interchange between a number of

Lifelines

:A :B participants: actors, objects, etc. involved in the use case

lifelines: represent the “lifetime” of a participant

time

Page 11: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

•  The most common kind of Interaction Diagrams •  shows how actors and objects interact to realize a use case

scenario •  focuses on the Message interchange between a number of

Lifelines

:A :B participants: actors, objects, etc. involved in the use case. Notation object:Class •  :Class = anObject:Class Kinds of participants: •  actor, class, database •  boundary, entity, control

lifelines: represent the “lifetime” of a participant

time

http://i.stack.imgur.com/rQPvd.gif

Page 12: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

What are all these things?

•  Boundary objects interface with actors. •  Entity objects represent system data, often from the domain. •  Control objects glue boundary elements and entity elements,

implementing the logic required to manage the various elements and their interactions.

•  Not every system should have boundary/entity/control objects.

/ SET / W&I PAGE 12 26/02/15

Page 13: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Back to sequence diagrams

•  The most common kind of Interaction Diagrams •  shows how actors and objects interact to realize a use case

scenario •  focuses on the Message interchange between a number of

Lifelines

/ SET / W&I PAGE 13 26/02/15

:A :B msg1 :A sends message msg2

to :B and waits for :B’s response: synchronous communication

msg2

response, return (optional)

Page 14: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

•  The most common kind of Interaction Diagrams •  shows how actors and objects interact to realize a use case

scenario •  focuses on the Message interchange between a number of

Lifelines

/ SET / W&I PAGE 14 26/02/15

:A :B msg1 Order of participants = order of the

first participation in the interaction Most of the message sends on arrows from left to right

msg2

response

Page 15: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

•  The most common kind of Interaction Diagrams •  shows how actors and objects interact to realize a use case

scenario •  focuses on the Message interchange between a number of

Lifelines

/ SET / W&I PAGE 15 26/02/15

:A :B msg1 Intuition: Messages are sent to

objects of classes with the corresponding operations. •  Class A has method msg1 •  Class B has method msg2

msg2

response

Page 16: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

•  The most common kind of Interaction Diagrams •  shows how actors and objects interact to realize a use case

scenario •  focuses on the Message interchange between a number of

Lifelines

/ SET / W&I PAGE 16 26/02/15

:A :B msg1

When a message is received by an object, a new activation is started. Activation is also known as execution specification.

msg2 activation

Page 17: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

•  Can we have multiple activations of the same object?

/ SET / W&I PAGE 17 26/02/15

:A :B msg1

When a message is received by an object, a new activation is started msg2

activation

Page 18: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

•  Can we have multiple activations of the same object? •  Yes! •  Activation resulting from message to self is slightly offset

from older activation

/ SET / W&I PAGE 18 26/02/15

:A :B msg1

msg2

msg

Page 19: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

If there is no concurrency, exactly one object is computing at any given instant

•  (Imaginary) horizontal line can cross only one “dark” area

:A :B msg1

msg2

msg

Page 20: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

If there is no concurrency, exactly one object is computing at any given instant

•  (Imaginary) horizontal line can cross only one “dark” area •  Activations behave as a stack

:A :B msg1

msg2

msg

A2 A1 Actor

A1 Actor B

A1 Actor

Page 21: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams

If there is no concurrency, exactly one object is computing at any given instant

•  (Imaginary) horizontal line can cross only one “dark” area •  Activations behave as a stack •  Only actors can send messages “out of the blue” −  Objects send messages only when they have been made active by

receiving a message from another participant

:A :B msg1

msg2

msg

A2 A1 Actor

A1 Actor B

A1 Actor

Page 22: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

What if we want concurrency?

Some communication might be asynchronous

:A :B

msg1

msg2

msg

Page 23: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Question for you

•  Messages are partially ordered (before/after) •  Response to msg should be received before msg2 is sent.

•  Why isn’t the order is total?

/ SET / W&I PAGE 23 26/02/15

Page 24: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Question for you

•  Messages are partially ordered (before/after) •  Response to msg should be received before msg2 is sent.

•  Why isn’t the order is total? •  independent events on different lifelines are not comparable −  e.g., concurrent execution resulting from asynchronous messages

/ SET / W&I PAGE 24 26/02/15

Page 25: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Creating and destroying objects

/ SET / W&I PAGE 25 26/02/15

:Girl

:Princess

getName() Prince Charming

n = getName(): Cinderella

destroy()

new Princess(n)

Label: assignment of return value to a variable; value returned shown after colon

Object destruction: synchronous message to the object with an X-terminating lifeline

Creating a new object: asynchronous message directly to the head of the new participant

Page 26: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Optional behavior

:Girl

:Princess

getName() Prince Charming

n = getName()

destroy()

new Princess(n)

Opt [n = Cinderella]

Continue with organizing the wedding

This is an example of a combined fragment introduced by the operator Opt (option). In total there are 13 operators. We’ll see 9 of them. guard

Page 27: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Combined fragments: loop and alternatives

/ SET / W&I PAGE 27 26/02/15 http://ptgmedia.pearsoncmg.com/images/chap4_0321193687/elementLinks/04fig04.gif

loop is potentially infinite. loop(10) indicates 10 iterations.

Page 28: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Combined fragments: loop and alternatives

/ SET / W&I PAGE 28 26/02/15 http://ptgmedia.pearsoncmg.com/images/chap4_0321193687/elementLinks/04fig04.gif

One can also break from the loop. break requires a guard. break quits only one nesting level.

Page 29: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

NB: Java/UML mismatches

•  Java semantics does not match UML semantics •  UML break

•  if the selected interaction occurs, the enclosing interaction is abandoned

•  Java break

for (j = 0; j < arrayOfInts.length; j++) {

if (arrayOfInts[j] == searchfor) { foundIt = true; break;

} }

/ SET / W&I PAGE 29 26/02/15

Rountev, Volgin, Reddoch PASTE’05

break quits only one nesting level.

Page 30: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

NB: Java/UML mismatche

•  Java semantics does not match UML semantics •  UML break

•  if the selected interaction occurs, the enclosing interaction is abandoned

•  Java break search:

for (i = 0; i < arrayOfInts.length; i++) { for (j = 0; j < arrayOfInts[i].length; j++) {

if (arrayOfInts[i][j] == searchfor) { foundIt = true; break search;

} }

} / SET / W&I PAGE 30 26/02/15

Rountev, Volgin, Reddoch PASTE’05

break quits only one nesting level.

Page 31: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Combined fragments: par, seq and strict

•  seq: •  Different lifelines: parallel •  The same lifeline: sequential

/ SET / W&I PAGE 31 26/02/15

Search Google, Bing and Ask in any order, possibly parallel.

Search Google, Bing and Yahoo in the strict sequential order.

Search Google possibly parallel with Bing and Yahoo, but search Bing before Yahoo.

Page 32: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Par: shorthand

•  Coregion: par-combined fragment with one lifeline

/ SET / W&I PAGE 32 26/02/15

The two fragments are equivalent

Page 33: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Combining different combined fragments

/ SET / W&I PAGE 33 26/02/15

http

://w

ww

.um

l-dia

gram

s.or

g/ex

ampl

es/s

eque

nce-

exam

ples

-onl

ine-

book

shop

.png

•  Coregion •  Option •  Loop •  Ref (interaction

use) allows to use (or call) another interaction.

Page 34: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Interaction use

In general, referencing should be done as DiagType DiagName [(ParType:ParName)] : [: RetValType] •  In practice, types are frequently omitted

•  Checkout – no parameters, no return value •  Debit Account (accountNumber, amount) – parameters, no

return value •  Balance Lookup (accountNumber): Real – parameters,

return value

/ SET / W&I PAGE 34 26/02/15

Page 35: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Interaction use

/ SET / W&I PAGE 35 26/02/15

Page 36: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Alternative way to represent a return value

/ SET / W&I PAGE 36 26/02/15

Gate: a message with one end connected to the sequence diagram's frame and the other end – to a lifeline.

Page 37: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Question for you

•  How to model exception handling in sequence diagram?

•  NB: UML provides neither notation to model exception handling in sequence diagrams nor any reasoning why it is absent.

•  Still, what would be your solution?

/ SET / W&I PAGE 37 26/02/15

Page 38: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Question for you

•  How to model exception handling in sequence diagram?

•  NB: UML provides neither notation to model exception handling in sequence diagrams nor any reasoning why it is absent.

•  Still, what would be your solution?

/ SET / W&I PAGE 38 26/02/15

Combined fragments alt/break

Page 39: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

What about constraints?

•  Constraint: boolean restriction on the participants of the interaction, usually verified at run time.

/ SET / W&I PAGE 39 26/02/15

Attribute t of Task should have value “complete”

State Invariant

Page 40: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

What about constraints?

•  Constraint: boolean restriction on the participants of the interaction, usually verified at run time.

/ SET / W&I PAGE 40 26/02/15

Attribute t of Task should have value “complete”

State Invariant

A transaction on SavingsAccount is permitted only if the balance remains positive.

Page 41: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

What about constraints?

•  Constraint: boolean restriction on the participants of the interaction, usually verified at run time.

/ SET / W&I PAGE 41 26/02/15

Response time constraint

Timing constraints

Scheduling constraint

Page 42: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

What about constraints?

•  Constraint: boolean restriction on the participants of the interaction, usually verified at run time.

/ SET / W&I PAGE 42 26/02/15

Prohibition: neg combined fragment

One cannot open the microwave door when it is cooking. Also notice the “from 1 to time” loop.

http://www.zicomi.com/combinedFragmentNegative.jsp

Page 43: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Summary of the combined fragments

Interaction operator of a combined fragment could be one of: •  alt – alternatives •  opt – option •  loop – iteration •  break – break •  par – parallel •  strict – strict sequencing •  seq – weak sequencing •  critical – critical region •  ignore – ignore •  consider – consider •  assert – assertion •  neg – negative •  ref – interaction use

/ SET / W&I PAGE 43 26/02/15

4 operators in italics have not been discussed. You are welcome to read about them in OMG UML version 2.5, Section 17.6.3, pp. 609-611.

Page 44: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Summary of the syntax

http://www.uml-diagrams.org/sequence-diagrams.html

Page 45: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Recall…

•  You draw a sequence diagram if, e.g.:

•  you have a use case diagram, to describe how the main components of the system interact

•  you have identified messages arriving at an interface of a component, to describe how the internal parts of the component interact.

/ SET / W&I PAGE 45 26/02/15

Page 46: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Building sequence diagrams

•  Set the context •  Identify participants that should interact to realize the use-case

scenario / to respond to messages arriving at the interface. •  Place the initiator of the interaction on the left of the diagram •  Multiple objects of the same class: name each

•  Set the lifeline for each participant •  Add messages by drawing arrows

•  Order messages from left to right, top to bottom •  Show how they are passed from one object to another •  Include any parameters in parentheses •  Exclude obvious return values

•  Add activations to each participant’s lifeline •  Validate the sequence diagram / SET / W&I PAGE 46 26/02/15

Page 47: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Validation

•  Recall: Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams

•  Rule: Objects in [sd] should be instances of classes in [cd] •  Rule: Name of the message [sd] should match an operation

in the receiver’s class [cd]

ATM

+withdrawCash(accountNumber, amount) http://www.ibm.com/developerworks/rational/library/3101.html

Page 48: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Validation

•  Recall: Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams

•  Rule: Objects in [sd] should be instances of classes in [cd] •  Rule: Name of the message [sd] should match an operation

in the receiver’s class [cd]

Girl +name

The message is a getter!

Page 49: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Validation

•  Recall: Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams

•  Rule: Objects in [sd] should be instances of classes in [cd] •  Rule: Name of the message [sd] should match an operation

in the receiver’s class [cd] •  Rule: If a message is sent from A to B [sd] then there

should be an association from the class of A to the class of B [cd]

•  Rule: If use-case A generalizes use-case B [ucd] then the sequence diagram of A should be a subgraph of the sequence diagram of B [sd].

Page 50: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Validation

•  Recall: Interaction diagrams should be consistent with the corresponding class diagrams and use case diagrams

•  Briand et al. mention 120 consistency rules •  http://squall.sce.carleton.ca/pubs/tech_report/TR_SCE-03-01.pdf

•  Active research domain around 2005 •  Prototype implementations •  Inconsistency detection vs. inconsistency resolution

Page 51: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Group assignment 2: Consistency! •  Are the sequence diagrams consistent with the class

diagram? •  Are the state machines consistent with the class diagram? •  Are there any inconsistencies between the behavior

described by the behavioral diagrams and the requirements?

•  Are the declarations consistent with the classes introduced in the class diagram?

/ SET / W&I PAGE 51 26/02/15

Page 52: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams as a specification technique?

Unambiguous? Realistic? Verifiable? Evolvable?

/ SET / W&I PAGE 52 26/02/15

Page 53: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams as a specification technique?

Unambiguous? •  more advanced features [seq, strict, …] are less clear (and

less popular) and might lead to ambiguity •  asynchronous communication is portrayed as if it was

simultaneous while it is not

is “Query” send before or after “Pressure” has been received? before or after “Pressure” has been send?

/ SET / W&I PAGE 53 26/02/15

[Sibertin-Blanc, Hameurlain, Tahir 2008]

Page 54: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Sequence diagrams as a specification technique?

Realistic? •  allows to model interaction, popular in the industry Verifiable? •  interactions can be replayed through testing •  omissions and inconsistencies are hard to spot •  [Guerra, de Lara 2003] propose a formal verification

approach based on Petri nets, but only for a restricted subclass of sequence diagrams

Evolvable? •  depends on the complexity/size •  affected by ambiguity

/ SET / W&I PAGE 54 26/02/15

Page 55: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Interaction diagrams

/ SET / W&I PAGE 55 26/02/15

Sequence Diagram

Timing Diagrams

Interaction Overview Diagram

Communication Diagram

Page 56: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Timing diagram

•  Interaction diagram for reasoning about time

•  Basic elements: lifelines, states, duration/time constraints, destruction, events, messages

http://www.uml-diagrams.org/timing-diagrams-examples.html#alzheimers

lifeline

finite set of discrete states

duration constraints

destruction

Page 57: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Timing diagram

•  Interaction diagram for reasoning about time

•  Basic elements: lifelines, states, duration/time constraints, destruction, events, messages

duration constraints

Compact representation with states and durations

Page 58: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Timing diagram

•  Interaction diagram for reasoning about time

•  Basic elements: lifelines, states, duration/time constraints, destruction, events, messages

time constraints

time observations

timing ruler

http://www.jot.fm/issues/issue_2006_05/article2/

Page 59: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Timing diagram

•  Interaction diagram for reasoning about time http://creately.com/blog/diagrams/uml-diagram-types-examples/#TimingDiagram

time constraints

time observation

message

Page 60: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Questions

Sketch a timing diagram for the following statements: a)  Ice should melt into water in 1 to 6 minutes. b)  Person should wake up between 5:40 am and 6 am. c)  Lifecycle of a virus: Dormant, Propagation, Triggering

and Execution.

/ SET / W&I PAGE 60 26/02/15

Page 61: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Questions

Sketch a timing diagram for the following statements: a)  Ice should melt into water in 1 to 6 minutes. b)  Person should wake up between 5:40 am and 6 am. c)  Lifecycle of a virus: Dormant, Propagation, Triggering

and Execution.

/ SET / W&I PAGE 61 26/02/15

http://www.uml-diagrams.org/timing-diagrams.html

a) b) c)

Page 62: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Timing diagrams as a specification technique?

Unambiguous? Realistic? Verifiable? Evolvable?

/ SET / W&I PAGE 62 26/02/15

Page 63: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Timing diagrams as a specification technique?

Unambiguous? •  ranges on messages: do they refer to message being

send or being received? Realistic? •  familiar to hardware engineers •  relatively unpopular [Reggio et al. MODELS 2013]

•  have a restricted scope •  alternatives: timed events in state machines and activity

diagrams; durations and time intervals may appear in sequence diagrams

/ SET / W&I PAGE 63 26/02/15

Page 64: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

Timing diagrams as a specification technique?

Verifiable? •  Cui et al. (2010) convert timing diagrams to timed

automata and verify using UPPAAL Evolvable? •  depends on the complexity/size •  can be affected by lack of popularity

/ SET / W&I PAGE 64 26/02/15

Page 65: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

UML diagram types: popularity

/ SET / W&I PAGE 65 26/02/15

100%

52%

80%

80% 70%

71% 98%

97%

82%

39%

40%

11%

96% 96%

Page 66: Interaction diagramsaserebre/2IW80/2014-2015/06... · Sequence diagrams • The most common kind of Interaction Diagrams • shows how actors and objects interact to realize a use

/ SET / W&I PAGE 66 26/02/15