Sie sind auf Seite 1von 28

Sequence Diagrams

Software Design Methodology

Outline
Introduction Basic notation Alternating paths Modularity

Modeling Process
Phase
Initiation Requirements Specification Design Implementation Testing & Integration Maintenance

Actions
Raising a business need

Outcome
Business documents

Interviewing stakeholders, exploring the Organized documentation system environment Analyze the engineering aspect of the system, building system concepts Define architecture, components, data types, algorithms Program, build, unit-testing, integrate, documentation Integrate all components, verification, validation, installation, guidance Bug fixes, modifications, adaptation Formal specification Formal Specification Testable system Testing results, Working sys System versions
3

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?


4

Behavioral Modeling

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

Behavior Modeling
Sequence Diagrams Activity Diagrams State Diagrams
Checkout Manager
message: create Check availability [problem] [okay]

Add to cart

Order In process

Order
message: change status

supplied

Inventory
Notify User Supply Order

* We will not talk about collaboration diagrams


6

Building a Sequence Diagrams


Sequence diagrams capture the use-case behavior using the foundation of the Use Case 1 Class C classes . Class A
Use Case 2 Class D Class B Use Case 3

therefore

Sequence =

Objects

messages
7

Sequence Diagrams

A simple sequence diagram:


sd Product Buying

objects

Diagram Name
customer display() getPrice()

p : Product

: ShooppingCart

message
addProduct (p) checkout ()

activation (focus of control) Life line

Object Control
obj1 : Class1 user operate() do () create () : Class3 obj2 : Class2

Object Creation

Return Message
foo()

Messages to self

Object Destruction
Illustration 9

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.

Illustration

10

Sequences and Use-Cases


p : Product customer display() getPrice() addProduct (p) checkout () create () : Order : ShooppingCart

Visible part

Hidden part
11

Full Message Attributes


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

C3.1: res := getLocation (fig)

sequence number

message name argument list

return value

12

Different Kinds of Messages


Synchronous Message

asynchronous Message

Return Message

13

Synchronous & Asynchronous Messages


Nested Flow
teller : Order
getValue price

Asynchronous Flow
appl err handl alarm

: Article

unknown ring

setID

log

Example

Example

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
14

Outline
Introduction Basic elements Alternating paths Modularity

15

Flow Constructs

If Loop ElseRepeat Jump


16

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

Options
msg : Message : Database

Fragment

opt
[msg.status=confirmed]
archive(msg)

Condition

Do something...

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

17

Alternatives
msg : Message : Database : Admin

alt
[msg.status=confirmed] archive(msg)

Alternative Fragment group

Condition
[msg.status=error] notify(msg.getID())

[else]
wait()

Else condition (optional)

Execution regions. At most one will execute.

18

Loops
: OS : Folder : File

loop

Loop Fragment

[for each Folder] Display()

loop
[for each File] Display()

Condition Nested Loop Fragment


19

Breaks
: User
isLooged = login(name,pass)

: User Manager

: Policy

break
[isLooged] addBadLogin(name)

If the condition is met, the break fragment is executed, and the reminder of the sequence is ignored Handy in model exception handling

Do something Do something

20

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

21

Outline
Introduction Basic elements Alternating paths Modularity

22

Modularity

We need ways to create modular scenarios


23

Referencing a diagram
: User ref Login Handling(user,pass) : bool : User Manager : Policy
login(name,pass)

Do something Do something

Reference Gate

24

Referenced Diagram
Diagram name
sd Login Handling : User Manager loop : UserAccount

Input message

login(name,pass) [for each UserAccount] cName -= getUseNamer()

Output message
true

opt
[cName = name] isInSystem(true)

false

25

Parallel Fragments
: User : Checkout Handler : Shipping Handler : Transaction Handler
provideDetails()

performCheckout()

par
Ship(address,products)

chargeMoney(CC,sum)

26

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

27

Summary

Behavior Modeling
Sequence models interaction

Language
Objects + lifeline Messages

Alternations
Loops Alternatives

Modularity
Referencing Parallel
28

Das könnte Ihnen auch gefallen