View
215
Download
1
Embed Size (px)
Citation preview
Jan 23, 2002 91. 3913 Ron McFadyen 1
: Cashier:System
addLineItem(itemID, quantity)
endSale()
makePayment(amount)
description, total
total with taxes
change due, receipt
* [more items]
makeNewSale()
these input system eventsinvoke system operations
the system eventmakeNewSale invokes asystem operation calledmakeNewSale and so forth
this is the same as in object-oriented programming whenwe say the message fooinvokes the method (handlingoperation) foo
SSD for a samplePOS Use Case Figure 13.1Input Events invoke a system operation of the same name
same idea as in object-oriented programming when we say a message foo invokes the method foo
Jan 23, 2002 91. 3913 Ron McFadyen 2
: Cashier:System
addLineItem(itemID, quantity)
endSale()
makePayment(amount)
description, total
total with taxes
change due, receipt
* [more items]
makeNewSale()
these input system eventsinvoke system operations
the system eventmakeNewSale invokes asystem operation calledmakeNewSale and so forth
this is the same as in object-oriented programming whenwe say the message fooinvokes the method (handlingoperation) foo
SSD for a samplePOS Use Case Figure 13.1Input Events invoke a system operation of the same name
same idea as in object-oriented programming when we say a message foo invokes the method foo
We’ll refer to this as the enterItem system operation
Jan 23, 2002 91. 3913 Ron McFadyen 3
Messages sent for enterItem( … ) Figures 17.8, 20.6
This diagram shows a collaboration among objects. The collaboration is a sequence of messages. They occur in response to the system event enterItem.
We’ll explain this diagram, but note that we’ll study the notation more thoroughly in future lectures
Jan 23, 2002 91. 3913 Ron McFadyen 4
Messages sent for enterItem( … ) Figures 17.8, 20.6
The messages are sent in the order: 1, 1.1, 2, 2.1, 2.2.
Jan 23, 2002 91. 3913 Ron McFadyen 5
Messages sent for enterItem( … ) Figures 17.8, 20.6
The diagram would be created if the designer thought the illustration would be useful … to communicate to someone how the system will work.
Jan 23, 2002 91. 3913 Ron McFadyen 6
Messages sent for enterItem( … ) Figures 17.8, 20.6
The system operation is received by the Register object. On page 314 you’ll note that Register has an enterItem method.
Jan 23, 2002 91. 3913 Ron McFadyen 7
Messages sent for enterItem( … ) Figures 17.8, 20.6
The register object sends a message to the product catalogue. (The register will eventually tell the sale object to create a line for this.)
Jan 23, 2002 91. 3913 Ron McFadyen 8
Messages sent for enterItem( … ) Figures 17.8, 20.6
The catalogue will search the catalogue data structure for the item that was scanned at the register.
Note that on Page 314 the Java code only has to invoke the get method for the HashMap.
Jan 23, 2002 91. 3913 Ron McFadyen 9
Messages sent for enterItem( … ) Figures 17.8, 20.6
The sale object is sent a message that will cause it to create a new sales line
Jan 23, 2002 91. 3913 Ron McFadyen 10
Messages sent for enterItem( … ) Figures 17.8, 20.6
A new sales line is created
Jan 23, 2002 91. 3913 Ron McFadyen 11
Messages sent for enterItem( … ) Figures 17.8, 20.6
The newly created sales line will be added to the collection of lines belonging to this sale.
Jan 23, 2002 91. 3913 Ron McFadyen 12
Domain Model
Use Case Model
•text
•diagram
•SSD
•System operation contracts
Design Model
Figure 13.3
Jan 23, 2002 91. 3913 Ron McFadyen 13
Contracts
A technique for describing system operations in terms of state changes to objects in a Domain Model
major proponent - Bertrand Meyer
based on concept of assertion
•a statement, a declaration, that must be true
•a false value indicates a bug
•UML has OCL - very formal syntax which we will ignore
•at the requirements gathering stage, these are informal and likely incomplete
Jan 23, 2002 91. 3913 Ron McFadyen 14
Contracts
Contract Components
Operation - name and parameters
Cross References - where operation used
Preconditions - assumptions about the state of the system or Domain Model objects
Postconditions - state of objects after the operation completes
•objects:any new ones? any attributes modified?
•associations: any new or modified associations?
Larman’s version is very informal - focus on what, not how
Jan 23, 2002 91. 3913 Ron McFadyen 15
SalesLineItem
quantity
Product Specification
itemID
Sale
1
1..*
*1Described by
Contained in
The part of the Domain Model that is relevant to enterItem( )
Jan 23, 2002 91. 3913 Ron McFadyen 16
Contracts
Example
Operation enterItem (itemID : ItemID, quantity : integer)
Cross References Use Case Process Sale
Preconditions There is a sale underway
Postconditions
- a SalesLineItem instance was created
- an association between the sale and the sales line item was created
- an attribute, quantity, was modified
- an association between the product specification and the sales line item was created
Jan 23, 2002 91. 3913 Ron McFadyen 17
OCL
Object Constraint Language
• UML has a formal language for specifying constraints on object-oriented models
context Salesperson:: sell ( item: Thing ) : Real
pre: self.sellableItems -> includes (item)
post: not self.sellableItems -> includes (item) and result=item.price
Jan 23, 2002 91. 3913 Ron McFadyen 18
Ch 15. Interaction Diagrams
Now, we are shifting towards design - how do the objects in the model interact?
Interaction Diagram - illustrates how objects collaborate to fulfill requirements - the messages that are sent from one object to another
•collaboration diagrams
•sequence diagrams
Jan 23, 2002 91. 3913 Ron McFadyen 19
SalesLineItem
quantity
Product Specification
itemID
Sale
makePayment()
1
1..*
*1Described by
Contained in
More of the Domain Model - we’ve included some methods
Register
makePayment()
Payment
create()
1*
1
1
Captured on
Paid by
Jan 23, 2002 91. 3913 Ron McFadyen 20
Figure 15.3 Collaboration Diagram
Jan 23, 2002 91. 3913 Ron McFadyen 21
Figure 15.4 Sequence Diagram