Top Banner
Sequence Diagrams Software Design Methodology
28

Sequence Diagrame

May 10, 2017

Download

Documents

peroor
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Sequence Diagrame

Sequence Diagrams

Software Design Methodology

Page 2: Sequence Diagrame

2

Outline

IntroductionBasic notationAlternating pathsModularity

Page 3: Sequence Diagrame

3

Modeling ProcessOutcomeActionsPhase

System versions

Testing results, Working sys

Testable system

Formal Specification

Formal specification

Organized documentation

Business documentsRaising a business needInitiation

Bug fixes, modifications, adaptationMaintenance

Integrate all components, verification, validation, installation, guidance

Testing & Integration

Program, build, unit-testing, integrate, documentationImplementation

Define architecture, components, data types, algorithmsDesign

Analyze the engineering aspect of the system, building system conceptsSpecification

Interviewing stakeholders, exploring the system environmentRequirements

Page 4: Sequence Diagrame

4

Why to Model Behavior?

How do we use the SMS Server interface? What is the order of executing the operations?

sendMessage, getStatus, Resend?getStatus, sendMessage, checkForMessages?

When do we use resend?

Page 5: Sequence Diagrame

5

Behavioral Modeling

Where are people coming from? Where are they going?How do they move from one space to the other?

Page 6: Sequence Diagrame

6

Behavior Modeling

In process

supplied

OrderCheckoutManager

Order

message: changestatus

Add to cart

Check availability

Supply Order

Notify User

[okay][problem]

Sequence Diagrams Activity Diagrams State Diagrams

* We will not talk about collaboration diagrams

Inventory

message: create

Page 7: Sequence Diagrame

7

Building a Sequence Diagrams

Class AClass C

Class BClass D

Use Case 1

Use Case 2Use Case 3

Sequence diagrams capture the use-casebehavior using the foundation of the classes.

therefore Sequence = Objects + messages

Page 8: Sequence Diagrame

8

Sequence Diagrams

p : Product : ShooppingCart

addProduct (p)

customerdisplay()

getPrice()

checkout ()

sd Product Buyingobjects

message

Life line

activation (focus of control)

Diagram Name

A simple sequence diagram:

Page 9: Sequence Diagrame

9

Object Control

obj1 : Class1 obj2 : Class2

do (…)

: Class3create (…)

obj1 : Class1

useroperate() Object

Creation

Object Destruction

Return Message

foo()Messages to

self

Illustration

Page 10: Sequence Diagrame

10

Illustration

Corresponding Class Diagram

Notice that a dependency exists whenever messages are passed between instances of the class

Dependencies can be overridden by associations, aggregations etc.

Page 11: Sequence Diagrame

11

Sequences and Use-Cases

p : Product : ShooppingCart

addProduct (p)

: Ordercreate (…)

customerdisplay()

getPrice()

checkout ()

Hidden partVisible part

Page 12: Sequence Diagrame

12

Full Message Attributes

C3.1: res := getLocation (fig)

sequence number

return valuemessage name argument list

[sequence-expression][return-value :=] [message-name] [(argument-list)]

Page 13: Sequence Diagrame

13

Different Kinds of Messages

Synchronous Message

asynchronous Message

Return Message

Page 14: Sequence Diagrame

14

Synchronous & Asynchronous Messages

teller : Order : Article

Nested Flow

getValue

price

setID

appl err handl alarm

Asynchronous Flow

unknown

ring

Price need to be finished, before teller can do another operation (getName)

Ring is executed, while the control flow is returned to err handle and appl

unknown

log

Example Example

Page 15: Sequence Diagrame

15

Outline

IntroductionBasic elementsAlternating pathsModularity

Page 16: Sequence Diagrame

16

Flow Constructs

When we tell a scenario, which types of alternatives do we need?

IfElseLoopRepeatJump

Page 17: Sequence Diagrame

17

Example

Options

archive(msg)

: Messagemsg : Database

opt

Do something...

[msg.status=confirmed]

Fragment

Condition

Used for modeling simple optional blocks.Has one operand; no "else" guard.

Page 18: Sequence Diagrame

18

Alternatives

archive(msg)

: Messagemsg : Database

Condition

: Admin

alt

notify(msg.getID())

wait()

[msg.status=confirmed]

[msg.status=error]

[else]

Else condition(optional)

Alternative Fragment group

Execution regions. At most one will execute.

Page 19: Sequence Diagrame

19

Loops

Display()

: OS : Folder : File

loop

loop

Display()

[for each Folder]

[for each File]

Loop Fragment

Condition

Nested Loop Fragment

Page 20: Sequence Diagrame

20

Breaks

isLooged = login(name,pass)

: User : User Manager : Policy

addBadLogin(name)

break

[¬isLooged]

Do something…

Do something …

If the condition is met, the break fragment is executed, and the reminder of the sequence is ignored

Handy in model exception handling

Page 21: Sequence Diagrame

21

Examples of Guards

[for each Object][5][i=1..5][status = okay]No guard means an infinite loop

Page 22: Sequence Diagrame

22

Outline

IntroductionBasic elementsAlternating pathsModularity

Page 23: Sequence Diagrame

23

Modularity

We need ways to create modular scenarios

Page 24: Sequence Diagrame

24

Referencing a diagram

login(name,pass)

: User : User Manager : Policy

Login Handling(user,pass) :bool

ref

Do something…

Do something …

Reference Gate

Page 25: Sequence Diagrame

25

Referenced Diagram

: User Manager UserAccount:

sd Login Handling

loop

cName -= getUseNamer()

[for each UserAccount]login(name,pass)

opt

[cName = name]

cName -= getUseNamer()

isInSystem(true)true

false

Diagram name

Input message

Output message

Page 26: Sequence Diagrame

26

Parallel Fragments

provideDetails(…)

: User : Checkout Handler

: Shipping Handler

performCheckout()

: Transaction Handler

parShip(address,products)

provideDetails(…)

chargeMoney(CC,sum)

Page 27: Sequence Diagrame

27

Critical Fragment

the region is treated atomically by the enclosing fragment (i.e. parallel fragment)No other operations can interfere while a critical region is executed

Page 28: Sequence Diagrame

28

SummaryBehavior ModelingSequence models interaction

LanguageObjects + lifelineMessages

AlternationsLoopsAlternatives

ModularityReferencing Parallel