2.6.3. structuring sds
DESCRIPTION
2.6.3. Structuring SDs. Normally a use case scenario is too long and complex to fit on a single (A4?) SD. We need to hierarchically structure SDs and decompose them into sub-SDs called by SD references. A reference is a pointer to another SD. - PowerPoint PPT PresentationTRANSCRIPT
2.6.3. Structuring SDsNormally a use case scenario is too long andcomplex to fit on a single (A4?) SD.
We need to hierarchically structure SDs and decompose them into
sub-SDs called by
SD references.1
A reference is a pointer to another SD.
References may not be circular or recursive.
2
Let us give a typical example. A simple dataexchange between two systems can bedivided into 3 phases:
• set-up communication/initialize• exchange data• close-down communication
We can specify the use case “successful dataexchange” as follows.
3
BA
Initialize
Exchange
Shutdown
SD Successful_Data_Exchange
ref
ref
ref
4
The symbol
denotes a sub-SD called name. Thus everySD has a symbolic name also. The keywordref stand for reference.
Then for the above example, we might have:
<name>ref
5
BA A B
“ready_to_send”
“ready_to_receive”
“finished”
“shutdown”
SD Initialize SD Shutdown
Notice these are “handshakes” between A and B.
We will specify the SD “Exchange” later.6
Note that a sub-SD does not synchronizetimelines.
i.e. either of A or B is free to leave sub-SDExchange without the other leavingsimultaneously.
Here’s another example to clarify the point.
7
BA A B
“hello”
SD Unsynchronised_Ref SD Sub-1
“goodbye”
Sub-1
“what?”
ref
8
Possible executions are either:1. hello2. what3. goodbye (A leaves Sub-1 late)or1. hello2. goodbye (A leaves Sub-1 early)3. what?
9
User System
“username”
“password?”
SD normal_log_in
“my_password”
Precondition: Power is on, operating system is
active, log-in menu is visible.
Postcondition: Power is on, operating system isactive, user is logged in under own profile, user’s
desktop is visible, log-in menu is not visible.
10
We introduce SD interaction operators
• alt : alternative choice of sections• par : parallel execution of several sections• loop : iterative execution of a section• opt : optional section that could be omitted• (exc : exception section to handle errors.)
11
Interaction Operator alt
An operator (possibly with a Boolean guard)used to define two or more alternatives, at most one of which will be taken.
Below, users u1 and u2 compete for Printer p.
Either u2 wins (top) or u1 wins (bottom)12
u1 : User u2 : User p : Printer
SD Alternatives
“print_1”
“print_2”
alt “accept_2”
“accept_1”
13
The only possible executions or traces for SDAlternatives are either :1. print_12. print_23. accept_2or1. print_12. print_23. accept_1
14
Interaction Operator par
An operator used to define two or more sections, all of which will be executed simultaneously
Compare par with alt!
Below, u1 and u2 both request aprint job in parallel and both are accepted.
15
u1:User u2:User p:Printer
SD Parallel
par“accept_1”
“print_1”
“print_2”“accept_2”
16
This time there are 6 possible executions . These represent all possible interleavings of the two subsections of par.
1. print_1 1. print_1 1. print_2 1.print_12. print_2 2. accept_1 2. accept_2 2.print_23. accept_1 3. print_2 3. print_1 3.accept_24. accept_2 4. accept_2 4. accept_1 4.accept_1
1. print_2 1. print_22. print_1 2. print_13. accept_1 3. accept_24. accept_2 4. accept_1
17
Interaction Operator loop
An operator (possibly with a Boolean guard, noguard = [true]) used to define a section thatmay be iterated finitely or infinitely many times.
Guard evaluated on each iteration. As well asBoolean guards we can bound the number of iterations.
18
Keywords :(1) loop <m, n>, loop at least m times and at most n
times, for fixed integer constants m, n.(2) loop <m, inf>, loop finitely often, but at least m
times. ( *not* infinitely often).(3) loop <inf, inf> loop at least infinitely
many times.(4) loop <n> = loop <n, n> .(5) loop = loop <1, inf> .(6) [ while <Boolean expression> ]
19
Important note: The parameters m, n are fixed constants, they are not variables which can be changed.
In the following example, the user polls aprinter until the printer becomes ready. When it becomes ready the printer prints the file.
20
Loop <0, inf>
alt “ready?”
“busy”
“ready?”
“ready?”
“yes”
“print(file)”
“printing”
u:User p:Printer
21
Interaction Operator Opt
An expression, possibly with a Boolean guard, [ <Boolean expression> ]
(no guard is the same as [true]) used to define an optional section which may or may not be executed (non -deterministic).
In the next example, A sends to B and may or may not get confirmation in time t< maxdelay before the nextsend.
22
opt “received”
“ok”
“send”
“send”
a:A b:B
[ t < maxdelay ]
23
Other Interaction Operators
neg – traces which are defined to be impossible
region – a critical region, i.e. traces cannot be interleaved by other events.
assert – all traces that involve the assertion being false are impossible (??)
24
3. Introduction to Live Sequence Charts LSC
The Play-Engine is an MS Windows-based tool for Live Sequence Charts:1. managing a requirements project of LSCs,2. graphically editing correct LSCs, (play-in),3. simulating a set of LSCs (play-out),4. analysing LSCs (model checking).
Menu bar
Tool bar
ProjectExplorerTree
Work area
An LSC Application GUI
Basic structure
Use cases
Requirements
structure
behaviour
Code
Systemmodel
LSCs (or MSCs or sequence diagrams)
object model diagrams +statecharts
Java, C++, etcTraditional system development
Basic structure
Use cases
Requirements
structure
behaviour
Code
Systemmodel
LSCs (or MSCs or sequence diagrams)
object model diagrams +statecharts
Java, C++, etcPlay-in/out in theDevelopmentLifecycle
played behaviour
play-outplay-in