System Sequence Diagrams relationships Behavior can be specified in - - PDF document

system sequence diagrams
SMART_READER_LITE
LIVE PREVIEW

System Sequence Diagrams relationships Behavior can be specified in - - PDF document

Specifying required behavior using the UML Class models describe objects and their System Sequence Diagrams relationships Behavior can be specified in terms of operation and Contracts and Contracts pre and postconditions, but behavior


slide-1
SLIDE 1

1

System Sequence Diagrams and Contracts

Eunjee Song SSDs and Contracts-1

and Contracts

Eunjee Song Computer Science Department Baylor University

Specifying required behavior using the UML

 Class models describe objects and their

relationships

 Behavior can be specified in terms of operation

pre and postconditions, but behavior is not the primary focus of a class model

Eunjee Song SSDs and Contracts2

primary focus of a class model

 Behavioral models at the requirements

level

 Interaction models: describe interactions

between actors and the system

 Contracts: Specify operations invoked by

actors.

Still doing... Requirements Analysis

 Focusing on the WHAT not the HOW  System sequence diagrams and how

they relate to use cases

Eunjee Song SSDs and Contracts3

S ale d a te . . . S a le s L in e Ite m q u a ntity 1 ..* 1 . . . . . . D o m ain M od e l U se -C a s e M o d el R e q uire - m e n ts B u s in e s s M o d e lin g S a m p le U P A rtifac t R elatio ns h ip s : S y s te m U se C a se T e xt system e ve n ts

C a shie r P roce ss S ale

use ca se n a m e s U se C a se D ia gram V isio n G lo ssa ry p a ra m eters an d re tu rn va lue d e ta ils P ro ce ss S a le 1 . C u sto m e r a rrive s ... 2 . C a sh ie r m a ke s ne w sa le . 3 . ...

Eunjee Song SSDs and Contracts4

O p e ra tio n: en te rIte m (… ) P o st-con d itio n s:

  • . . .

O p e ra tio n C o n tra c ts D e sign M o d e l : R e g ister e n te rIte m (ite m ID , q u a n tity) : P ro d u ctC atalog sp e c = g e tP ro d u ctS p e c ( item ID ) a dd L in e Ite m ( sp e c, q u a n tity ) : S a le D e s ig n : S y s te m en te rIte m (id , qu a n tity ) S y s te m S e q ue n c e D ia g ra m s m ak e N e w S a le ()

: C ash ier

syste m

  • p eratio ns

S u pp le m e n ta ry S p e cificatio n sta rtin g e ven ts to d e sig n fo r

System Sequence diagrams

 Describes in more detail a scenario in a

use case

 Created from the text of the use case

 A kind of UML sequence diagram

Eunjee Song SSDs and Contracts5

 SSD is a simplified version of SD 

useful for requirements analysis

 More general version of sequence diagrams:

later, when talking about design

 Example: Process Sale for POS system

SSD Example

enterItem(itemID quantity) :System : Cashier a UML loop interaction external actor to system Process Sale Scenario system as black box the name could be "NextGenPOS" but "System" keeps it simple the ":" and underline imply an instance, and are explained in a later chapter on sequence diagram notation in the UML makeNewSale [ more items ] loop

Eunjee Song SSDs and Contracts6

enterItem(itemID, quantity) endSale makePayment(amount) interaction frame, with a boolean guard expression a message with parameters it is an abstraction representing the system event of entering the payment data by some mechanism description, total return value(s) associated with the previous message an abstraction that ignores presentation and medium the return line is

  • ptional if nothing is

returned total with taxes change due, receipt

slide-2
SLIDE 2

2 Elements of SSD

 Actors

 UML notation for an object

 System events

 Cashier generates makeNewSale,

Eunjee Song SSDs and Contracts7

enterItem, and endSale system events

 (Optional) information from the system

back to the actors

 item description, running total, etc.

Different Kinds of Arrows

Synchronous flow: e.g., Procedure call

Eunjee Song SSDs and Contracts8

Asynchronous flow Return

SSDs and Use Cases for “Process Sale”

Simple cash-only Process Sale scenario:

  • 1. Customer arrives at a POS checkout

with goods and/or services to purchase.

  • 2. Cashier starts a new sale.
  • 3. Cashier enters item identifier.

4 S d l li i d : Cashier :System enterItem(itemID, quantity) description total makeNewSale [ more items ] loop Process Sale Scenario Eunjee Song SSDs and Contracts9

  • 4. System records sale line item and

presents item description, price, and running total. Cashier repeats steps 3

  • 4 until indicates

done.

  • 5. System presents total with taxes

calculated.

  • 6. Cashier tells Customer the total, and

asks for payment.

  • 7. Customer pays and System handles

payment. ... endSale makePayment(amount) description, total total with taxes change due, receipt

SSD for “Process Sale (cont)

 System presents total with taxes. To

determine taxes, System uses an external Tax Calculator.

Eunjee Song SSDs and Contracts10

SSD for “Process Sale (cont)

 Cashier enters cash amount tendered, and

System presents change due

 System presents receipt  System logs completed sale and sends

sale info to the external Accounting

Eunjee Song SSDs and Contracts11

sale info to the external Accounting system and to the external Inventory system

Payment SSDs

makeCreditPayment (credNum, expiryDate) reply = requestApproval( request ) :Customer postReceivable( receivable ) :NextGenPOS System «actor» :CreditAuthorization Service «actor» :Accounts Eunjee Song SSDs and Contracts12 postSale( sale )

slide-3
SLIDE 3

3

SSD Sketches

Eunjee Song SSDs and Contracts13

Abstractions in SSDs

 Events and return values are abstractions

 Independent of mechanism & representation

 makePayment(amount)

 Shows input info

Eunjee Song SSDs and Contracts14

 Looks like a method call, but is really an

abstraction of an event

 Name: should capture the intent

 Avoid specifying implementation choices  enterItem(itemID) is better than scan(itemID)

 .

Timeline for SSDs

 SSDs are created during elaboration

 Clarify the major events that the system

should be able to handle

 Later we design objects to handle these

events (object oriented design)

Eunjee Song SSDs and Contracts15

events (object-oriented design)

 SSDs are created for some chosen

scenarios from the current iteration

 Happy path + frequent/complex

alternatives.

Contracts

: Cashier enterItem(itemID, quantity) description, total makeNewSale() these input system events invoke system operations the system event enterItem invokes a system operation [ more items ] loop :System Process Sale Scenario Eunjee Song SSDs and Contracts16 endSale() makePayment(amount) total with taxes change due, receipt called enterItem and so forth this is the same as in object-

  • riented programming when

we say the message foo invokes the method (handling

  • peration) foo

Contract Definition

 A system operation is a behavior that is invoked by

a user

 A contract specifies a system operation in terms of

pre- and postconditions

 Precondition: what must be true about concepts

represented in the domain model before the start of the

Eunjee Song SSDs and Contracts17

represented in the domain model before the start of the

  • peration

 Postcondition: what must be true about concepts

represented in the domain model after the operation has ended

Include instances created or deleted, new attribute values, links created or deleted

Contract Examples

 Stand-alone system

 No external inventory system

 Adding items to the inventory

 An instance of Item is created  The new instance is associated with the

Eunjee Song SSDs and Contracts18

 The new instance is associated with the

Store

 Removing items from the inventory

 The association is destroyed and the Item

instance is also destroyed

slide-4
SLIDE 4

1

Sales Product Catalog Product Description itemID description price Used-by

*

Contains 1..* Describes

*

Records-sale-of 0..1 1 1 1 Ledger Records- accounts- for 1 Register id Item Store name address Sale dateTime / total LineItem quantity Stocks

*

Houses 1..* Captured-on Contained-in 1..* Logs- completed

*

1 1 1..* 1 1 0..1 1 1 Eunjee Song SSDs and Contracts19 CashPayment amountTendered Cashier id Customer Paid-by Is-for Works-on 1 1 1 1 1 1

Contract Example 1 - makeNewSale

Operation: makeNewSale() Cross References: Use Case – Process Sale Precondition: An authenticated cashier c is Precondition: An authenticated cashier, c, is logged-in at a Register, r. Postcondition:

 A Sale instance, s, was created;  Attributes of s were initialized.  s was associated with r

Eunjee Song SSDs and Contracts20

 s was associated with r.

slide-5
SLIDE 5

2

Contract Example 2 - enterItem

Operation: enterItem(itemID:ItemID, quantity:integer) Cross References: Use Case – Process Sale Cross References: Use Case Process Sale Precondition: current sale object, s, exists Postcondition:

 A SalesLineItem instance, sli, was created;  sli was associated with s  sli quantity = quantity

Eunjee Song SSDs and Contracts21

 sli.quantity = quantity  sli was associated with a ProductDescription,

based on itemID match

Sales Product Catalog Product Description itemID description price Used-by

*

Contains 1..* Describes

*

Records-sale-of 0..1 1 1 1 Ledger Records- accounts- for 1

Contract Example - enterItem

Register id Item Store name address Sale dateTime / total LineItem quantity Stocks

*

Houses 1..* Captured-on Contained-in 1..* Logs- completed

*

1 1 1..* 1 1 0..1 1 1

Precondition: current sale object, s, exists Postcondition:

 A SalesLineItem instance, sli, was

created;

Eunjee Song SSDs and Contracts22 CashPayment amountTendered Cashier id Customer Paid-by Is-for  Works-on 1 1 1 1 1 1

 sli was associated with s  sli.quantity = quantity  sli was associated with an Item, based

  • n itemID match
slide-6
SLIDE 6

3

SSD/Contract Exercise - University

Registration System

Eunjee Song SSDs and Contracts23

Process Registration Use Case for the University Registration System

 A student arrives at the Registrar’s office in order to enroll

in one or more classes. The clerk will access the terminal in

  • rder to initiate a new enrollment session (you may assume

that they already have been authenticated by the system). Each enrollment session captures the date and time it was

  • initiated. The clerk will proceed to enroll the student in each

class requested. For each class, the clerk will enter the student name and identification number and the class identification number. In response to each entry, the t ill di l d i ti d fi ti At th

Eunjee Song SSDs and Contracts24

system will display a description and a confirmation. At the end of the session, the system will display a confirmation of the procedure and the total amount of tuition fees due. The clerk will then initiate a payment of tuition fees and the system will respond with the change due and a receipt.

slide-7
SLIDE 7

4

Domain Model (incomplete)

Eunjee Song SSDs and Contracts25

SSD for Process Registration

Eunjee Song SSDs and Contracts26

slide-8
SLIDE 8

5

Operation Contract

Contract CO1: makeNewEnrollment Operation: makeNewEnrollment () Cross References: Use Cases: Process Registration. Cross References: Use Cases: Process Registration. Pre-conditions: Post-conditions:

Eunjee Song SSDs and Contracts27

Combined Fragment Types

 Loop (loop)

 Optional guard: [<min>, <max>, <Boolean-expression>]  No guard means no specified limit  No guard means no specified limit

 Alternatives (alt)

 choice of behaviors – at most one will execute  depends on the value of the guard (“else” guard supported)

 Option (opt)

 Special case of alternative

Eunjee Song SSDs and Contracts28

 Parallel (par)

 Concurrent (interleaved) sub-scenarios

slide-9
SLIDE 9

6

Eunjee Song SSDs and Contracts29 

Acknowledgements: This lecture material is prepared based on

slides by Craig Larman and Dr. Robert France (CSU)