28
Sequence Diagrams Software Design Methodology

Sequence Diagrame

  • Upload
    peroor

  • View
    232

  • Download
    0

Embed Size (px)

Citation preview

Sequence Diagrams

Software Design Methodology

2

Outline

IntroductionBasic notationAlternating pathsModularity

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

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?

5

Behavioral Modeling

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

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

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

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:

9

Object Control

obj1 : Class1 obj2 : Class2

do (…)

: Class3create (…)

obj1 : Class1

useroperate() Object

Creation

Object Destruction

Return Message

foo()Messages to

self

Illustration

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.

11

Sequences and Use-Cases

p : Product : ShooppingCart

addProduct (p)

: Ordercreate (…)

customerdisplay()

getPrice()

checkout ()

Hidden partVisible part

12

Full Message Attributes

C3.1: res := getLocation (fig)

sequence number

return valuemessage name argument list

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

13

Different Kinds of Messages

Synchronous Message

asynchronous Message

Return Message

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

15

Outline

IntroductionBasic elementsAlternating pathsModularity

16

Flow Constructs

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

IfElseLoopRepeatJump

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.

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.

19

Loops

Display()

: OS : Folder : File

loop

loop

Display()

[for each Folder]

[for each File]

Loop Fragment

Condition

Nested Loop Fragment

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

21

Examples of Guards

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

22

Outline

IntroductionBasic elementsAlternating pathsModularity

23

Modularity

We need ways to create modular scenarios

24

Referencing a diagram

login(name,pass)

: User : User Manager : Policy

Login Handling(user,pass) :bool

ref

Do something…

Do something …

Reference Gate

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

26

Parallel Fragments

provideDetails(…)

: User : Checkout Handler

: Shipping Handler

performCheckout()

: Transaction Handler

parShip(address,products)

provideDetails(…)

chargeMoney(CC,sum)

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

28

SummaryBehavior ModelingSequence models interaction

LanguageObjects + lifelineMessages

AlternationsLoopsAlternatives

ModularityReferencing Parallel