Bài giảng Công nghệ phần mềm nâng cao - Phạm Ngọc Hùng - Biểu đồ tuần tự (Sequence Diagrams)

Outline

„Introduction

„Basic notation

„Alternating paths

„Modularity

pdf28 trang | Chuyên mục: Công Nghệ Phần Mềm | Chia sẻ: dkS00TYs | Lượt xem: 1994 | Lượt tải: 2download
Tóm tắt nội dung Bài giảng Công nghệ phần mềm nâng cao - Phạm Ngọc Hùng - Biểu đồ tuần tự (Sequence Diagrams), để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
Sequence Diagrams
Software Design Methodology
2Outline
„ Introduction
„ Basic notation
„ Alternating paths
„ Modularity
3Modeling Process
OutcomeActionsPhase
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
4Why 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?
5Behavioral Modeling
„ Where are people coming from? 
„ Where are they going?
„ How do they move from one space to the other?
6Behavior Modeling
In process
supplied
OrderCheckout
Manager
Order
message: change
status
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
7Building a Sequence Diagrams
Class A
Class C
Class B
Class D
Use Case 1
Use Case 2
Use Case 3
Sequence diagrams capture the use-case
behavior using the foundation of the 
classes. 
therefore Sequence = Objects + messages
8Sequence Diagrams
p : Product : ShooppingCart
addProduct (p)
customer
display()
getPrice()
checkout ()
sd Product Buying
objects
message
Life line
activation 
(focus of 
control) 
Diagram 
Name
„ A simple sequence diagram:
9Object Control
obj1 : Class1 obj2 : Class2
do (…)
: Class3
create (…)
user
operate() 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)
: Order
create (…)
customer
display()
getPrice()
checkout ()
Hidden partVisible part
12
Full Message Attributes
C3.1: res := getLocation (fig)
sequence number
return value
message 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
log
Example Example
15
Outline
„ Introduction
„ Basic elements
„ Alternating paths
„ Modularity
16
Flow Constructs
When we tell a scenario, which types of alternatives 
do we need? 
If
ElseLoopRepeatJump
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
„ Introduction
„ Basic elements
„ Alternating paths
„ Modularity 
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]
isInSystem(true)
true
false
Diagram 
name
Input 
message
Output 
message
26
Parallel Fragments
provideDetails(…)
: User : Checkout Handler
: Shipping 
Handler
performCheckout()
: Transaction 
Handler
par
Ship(address,products)
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
Summary
9 Behavior Modeling
Sequence models interaction
9 Language
Objects + lifeline
Messages
9 Alternations
Loops
Alternatives
9 Modularity
Referencing 
Parallel

File đính kèm:

  • pdfBài giảng Công nghệ phần mềm nâng cao - Phạm Ngọc Hùng - Biểu đồ tuần tự (Sequence Diagrams).pdf