interaction diagrams - rose–hulman institute of technology

32
Interaction Diagrams Curt Clifton Rose-Hulman Institute of Technology

Upload: others

Post on 26-Apr-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Interaction Diagrams - Rose–Hulman Institute of Technology

Interaction DiagramsCurt Clifton

Rose-Hulman Institute of Technology

Page 2: Interaction Diagrams - Rose–Hulman Institute of Technology

Anonymous Feedback“ There is not enough information in the partial use cases, scope and requirements to go into the type of depth an operational contract with any type of certainty. This is taking too much time having to “come up” with details that should have already been laid out by the requirements document and easily accessible.”

OCs are part of the requirements

You have the domain model, which is most pertinent

This course is all about dealing with uncertainty and resolving it

You won’t be penalized for answers that are different than mine so long as they follow the guidelines

Page 3: Interaction Diagrams - Rose–Hulman Institute of Technology

What Matters Most?

Principles of assigning responsibilities to objects

Design patterns

But we need some notation

to communicate these ideas

Page 4: Interaction Diagrams - Rose–Hulman Institute of Technology

Interaction Diagrams

For dynamic object modeling

Two common types:

Sequence diagrams

Communication diagrams

Don’t confuse with System Sequence Diagrams (SSDs),

which use a subset of the notation

Q1,2

Page 5: Interaction Diagrams - Rose–Hulman Institute of Technology

Sequence DiagramExample

public class A { private B myB = new B(); public void doOne() { myB.doTwo(); myB.doThree(); }}

Page 6: Interaction Diagrams - Rose–Hulman Institute of Technology

Communication Diagram Example

public class A { private B myB = new B(); public void doOne() { myB.doTwo(); myB.doThree(); }}

Page 7: Interaction Diagrams - Rose–Hulman Institute of Technology

Relative Strengths

Sequence diagrams

Clearer notation and semantics

Better tool support

Easier to follow

Excellent for documents

Communication diagrams

Much more space efficient

Easier to modify quickly

Excellent for UML as sketch

Page 8: Interaction Diagrams - Rose–Hulman Institute of Technology

Why Bother with Interaction Diagrams?

Keep us from getting bogged down in syntax

Can allocate responsibilities with minimal commitment

But don’t get bogged down

Page 9: Interaction Diagrams - Rose–Hulman Institute of Technology

Common Notation

Page 10: Interaction Diagrams - Rose–Hulman Institute of Technology

Lifeline Boxes

Q3

Page 11: Interaction Diagrams - Rose–Hulman Institute of Technology

Message Syntax

id = message(parameter : parameterType) : returnType

Much is optional, for example:

initialize(register)initialized = getProductDescription(id)d = getProductDescription(id:ItemID)d = getProductDescription(id:ItemID) : ProductDesc

Page 12: Interaction Diagrams - Rose–Hulman Institute of Technology

Sequence Diagrams

Page 13: Interaction Diagrams - Rose–Hulman Institute of Technology

:Register :SaledoX

doA

doB

doC

doD

Terminology

Found message

Execution specification bars

Synchronous messages

Q4

Page 14: Interaction Diagrams - Rose–Hulman Institute of Technology

Two Ways of Illustrating Return Values

Page 15: Interaction Diagrams - Rose–Hulman Institute of Technology

Messages to Self

Page 16: Interaction Diagrams - Rose–Hulman Institute of Technology

Instance Creation conventional message name

Note dashed line!

Page 17: Interaction Diagrams - Rose–Hulman Institute of Technology

Instance Destruction

“stereotype”

Page 18: Interaction Diagrams - Rose–Hulman Institute of Technology

Cartoon of the Day

General solutions get you a 50% tip

http

://x

kcd.

com

/287

/

Page 19: Interaction Diagrams - Rose–Hulman Institute of Technology

Speaking of Sales…Recall Interaction Frames

Frame operator

Guard

Page 20: Interaction Diagrams - Rose–Hulman Institute of Technology

Common Frame Operators

Operator Meaning

alt

loop

opt

par

region

ref

sd

“alternative”, if-then-else or switch

loop while guard is true, or loop(n) times

optional fragment executes if guard is true

parallel fragments

critical region (single threaded)

a “call” to another sequence diagram

a sequence diagram that can be “called”

Page 21: Interaction Diagrams - Rose–Hulman Institute of Technology

Mutual Exclusion “alt” Frame

Divides sections of frame Q5

Page 22: Interaction Diagrams - Rose–Hulman Institute of Technology

Iterating Over a Collection—Version 1

Action box contains arbitrary statements from implementation language

One instance from a collection

Page 23: Interaction Diagrams - Rose–Hulman Institute of Technology

Iterating Over a Collection—Version 2

Leaves the loop implicit.

Page 24: Interaction Diagrams - Rose–Hulman Institute of Technology

Abstracting Interaction

Interaction occurrence ref frames

sd framesQ6

Page 25: Interaction Diagrams - Rose–Hulman Institute of Technology

:GameStarter :Game

:ClockstartGame

create

run

beginPlay

Asynchronous Calls

Asynchronous (non-blocking) call

Synchronous (blocking) call

Q7

Active object has its own thread

Page 26: Interaction Diagrams - Rose–Hulman Institute of Technology

And now for something completely different

Page 27: Interaction Diagrams - Rose–Hulman Institute of Technology

Communication Diagrams

Page 28: Interaction Diagrams - Rose–Hulman Institute of Technology

Links vs. Messages

Single link connects two objects

Multiple messages

traverse links

Sequence number gives ordering

Q8

Page 29: Interaction Diagrams - Rose–Hulman Institute of Technology

Sequence Numbering

No number on found message

Nested messages use “legal” style

Page 30: Interaction Diagrams - Rose–Hulman Institute of Technology

Conditional MessagesUse Guards

Q9a

Page 31: Interaction Diagrams - Rose–Hulman Institute of Technology

Iteration Uses Stars

Q9b

Page 32: Interaction Diagrams - Rose–Hulman Institute of Technology

:GameStarter :Game

:Clock

startGame

1: create

2: run

3: beginPlay

Asynchronous Calls

Asynchronous (non-blocking) call

Synchronous (blocking) call

Q10

Active object