Presentation is loading. Please wait.

Presentation is loading. Please wait.

Operation Contracts. Primary way to describe system behavior is with use cases Operation contracts provide more details in terms of state changes to objects.

Similar presentations


Presentation on theme: "Operation Contracts. Primary way to describe system behavior is with use cases Operation contracts provide more details in terms of state changes to objects."— Presentation transcript:

1 Operation Contracts

2 Primary way to describe system behavior is with use cases Operation contracts provide more details in terms of state changes to objects in domain model after system operation has executed  postconditions

3 Contract CO2: enterItem Operation:enterItem(itemID : ItemID, quantity : integer) Cross references:Process Sale use case Preconditions:There is a sale underway 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)

4 Fig. 11.1

5 Format of Operation Contract Contract sections: –Operation – name and parameters –Cross References – use cases that apply –Preconditions –Postconditions

6 Operation Contracts Postconditions – describe changes in state of objects in the domain model including: Instances created and deleted Associations formed or broken Attributes changed

7 Operation Contracts Similar to use case but provides more detail Expressed in a declarative form not as an action Provide more detail on postconditions Postconditions expressed in past tense

8 Operation Contracts Guideline: How to create and write contracts: –Identify system operations from SSDs –Construct a contract for those system operations that are complex or subtle in their results –Describe postconditions using terms: Instance creation/deletion Attribute modification Associations formed/broken

9 Contract CO1: makeNewSale Operation:makeNewSale() Cross references:Process Sale use case Preconditions:None Postconditions:- A Sale instance s was created (instance creation) - s was associated with a Register (association formed) - Attributes of s were initialized

10 Fig. 9.27

11 Contract CO3: endSale Operation:endSale() Cross references:Process Sale use case Preconditions:There is a sale underway Postconditions:- Sale.isComplete became true (attribute modification)

12 Contract CO4: makePayment Operation:makePayment(amount : Money) Cross references:Process Sale use case Preconditions:There is a sale underway Postconditions:- A Payment instance p was created (instance creation) - p.amountTendered became amount (attribute modification) - p was associated with the current Sale (association formed) - The current Sale was associated with the Store (association formed)


Download ppt "Operation Contracts. Primary way to describe system behavior is with use cases Operation contracts provide more details in terms of state changes to objects."

Similar presentations


Ads by Google