operation contracts: getting ready to open the “system” black box all material from applying uml...

23
Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11.

Upload: drusilla-holt

Post on 03-Jan-2016

227 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Operation Contracts: Getting ready to open the “System”

black box

All material from Applying UML and Patterns, 3rd Edition, Craig

Larman, chapter 11.

Page 2: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Operation Contract Considered part of the Use Case Model

because they provide more analysis detail on the effect of the system operations implied in the use cases

Page 3: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Operation Contracts

Define the effect of the system operations on the domain model objects

Page 4: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

System Operations

Operations that the system as a black box offers in its public interface

Page 5: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Public System Interface

The entire set of system operations across all use cases defines the public system interface, viewing the system as a single component or class.

Page 6: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

System Operations

Prime inputs to the contracts are the system operations identified in SSDs and the domain model

Contracts in turn serve as input to the object design as they describe changes that are likely required in the software objects or database.

Page 7: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Fig. 11.1

Operation: enterItem(…)

Post-conditions:- . . .

Operation Contracts

Sale

date. . .

SalesLineItem

quantity

1..*1 . . .

. . .

Domain Model

Use-Case Model

Design Model: Register

enterItem(itemID, quantity)

: ProductCatalog

spec = getProductSpec( itemID )

addLineItem( spec, quantity )

: Sale

Require-ments

Business Modeling

Design

Sample UP Artifact Relationships

: System

enterItem(id, quantity)

Use Case Text

System Sequence Diagrams

makeNewSale()

system events

Cashier

Process Sale

: Cashier

use case

names

system operations

Use Case Diagram

Vision

SupplementarySpecification

Glossary

starting events to design for, and more detailed requirements that must be satisfied by the software

Process Sale

1. Customer arrives ...2. ...3. Cashier enters item identifier.

the domain objects, attributes, and associations that undergo changes

requirements that must be satisfied by the software

ideas for the post-conditions

Page 8: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

System Operations

Can be identified in SSDs

Page 9: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Operation Contracts

Text, Figure 11.2

: Cashier

enterItem(itemID, quantity)

endSale()

makePayment(amount)

description, total

total with taxes

change due, receipt

makeNewSale()

these input system events invoke system operations

the system event enterItem invokes a system operation called enterItem and so forth

this is the same as in object-oriented programming when we say the message foo invokes the method (handling operation) foo

[ more items ]loop

:System

Process Sale Scenario

Page 10: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Sections of an Operation Contract Operation: Name of the operation and parameters Cross References: Use cases and scenarios this

operation can occur within Preconditions: Noteworthy assumptions about the

state of the system or objects in the Domain Model before execution of the operation.

Postconditions: This is the most important section. The state of objects in the Domain Model after completion of the operation

Page 11: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Postconditions: most important

Describe changes in the state of objects in the domain model after completion of the operation

what instances were created ? what associations were formed/broken? what attributes changed?

Are not actions to be performed during the operation

Page 12: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Examples of Operation Contracts

from Process Sale Use Case (Fig.11.9)

Page 13: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Operation: makeNewSale() Cross References:

Use Case: Process Sale Scenario: Process Sale

Preconditions: none Postconditions

a sale instance “s” was created (instance creation) s was associated with the Register (association

formed) attributes of s were initialized

Operation Contract for makeNewSale operation

Page 14: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

What this looks like:

s :Sale

saleDate = currentDate()saleTim e = currentTime()saleNum = nextSaleNum()isCom plete = false

Regis ter111 1

association was created

s:Sale was created

attributes of s:Sale were initialized

Page 15: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Example—Operation Contract for enterItem operation Operation: enterItem(itemID,quantity) Cross References:

Use Case: Process Sale Scenario: Process Sale

Preconditions: There is a sale underway.

Page 16: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Example—Operation Contract for enterItem operation Postconditions:

A salesLineItem instance sli was created (instance creation)

sli was associated with the current Sale (association formed)

sli.quantity became quantity (attribute modification)

sli was associated with a ProductDescription, based on itemId match (association formed)

Page 17: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

What this looks like:

s:Sale

saleDatesaleTimesaleNumisComplete

ProductSpecification

sli:SalesLineItem

quantity1 1..n1 1..n

n

11

n

associations were created

sli:SalesLineItem was createdsli.quantity was initialized to input quantity

Page 18: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Operation: endSale() Cross References:

Use Case: Process Sale Scenario: Process Sale

Preconditions: There is a sale underway Postconditions

s.isComplete became true (attribute modification)

Example—Operation Contract for endSale operation

Page 19: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

What this looks like:

s :Sale

saleDatesaleTimesaleNumisCom plete

s.isComplete became true

Page 20: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Operation: makePayment(amount:Money) Cross References:

Use Case: Process Sale Scenario: Process Sale

Preconditions: There is a sale underway

Example—Operation Contract for makePayment operation

Page 21: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Postconditions a payment instance “p” was created (instance

creation) p.amountTendered became amount (attribute

modification) p was associated with s:Sale (association former) s:Sale was associated with the Store (association

formed)

Example—Operation Contract for makePayment operation

Page 22: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

What this looks like:

p:Payment

amountTendered

Store

s:Sale

saleDatesaleTimesaleNumisComplete

11 11

n

1

n

1

associations were created

p:Payment was createdp.amountTendered was initialized to input amount

Page 23: Operation Contracts: Getting ready to open the “System” black box All material from Applying UML and Patterns, 3 rd Edition, Craig Larman, chapter 11

Why Operation Contracts?

An excellent tool of OO requirements analysis that describes in great detail the changes required by a system operation (in terms of the domain model objects) without having to describe how they are to be achieved

Excellent preparation for opening the System black box!