11 Mapping Design To Code
11 Mapping Design To Code
Code
Larman, Chapter 20
CSE432
Object Oriented Software
Engineering
OO development is iterative
OOA/D artifacts feed into implementation
model in a traceable manner
Some tools generate partial code from
UML
But programming not trivial generation!
Programmers make changes as the work
out the details
Therefore, Expect and plan for change and
deviation from design during programming
SalesLineItem
quantity : Integer
ProductDescription
description
1
getSubtotal() : Money
description : Text
price : Money
itemID : ItemID
...
Fig. 20.1
enterItem(id, qty)
2: makeLineItem(desc, qty)
:Register
1: desc := getProductDescription(id)
:Product
Catalog
Fig. 20.4
:Sale
Collection classes
Sale
isComplete : Boolean
time : DateTime
becomeComplete()
makeLineItem()
makePayment()
getTtotal()
A collection class is necessary to
maintain attribute visibility to all the
SalesLineItems.
Fig. 20.5
SalesLineItem
lineItems
1..*
quantity : Integer
getSubtotal()
Exception handling
Why
Store
address : Address
name : Text
1
ProductCatalog
addSale(...)
1
1
Register
1..*
getProductDesc(...)
SalesLineItem
becomeComplete()
makeLineItem(...)
makePayment(...)
getTotal()
...
1..*
quantity : Integer
getSubtotal()
Payment
1
Fig. 20.7
description : Text
price : Money
itemID : ItemID
...
isComplete : Boolean
time : DateTime
...
endSale()
enterItem(...)
makeNewSale()
makePayment(...)
...
Sale
ProductDescription
amount : Money
...