Professional Documents
Culture Documents
Mapping Designs To Code: Larman, Chapter 20 CSE432 Object Oriented Software Engineering
Mapping Designs To Code: Larman, Chapter 20 CSE432 Object Oriented Software Engineering
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
Mapping Designs to Code
Write source code for:
– Class and interface definitions
– Method definitions
Work from OOA/D artifacts
– Create class definitions for Domain Class
Diagrams (DCDs)
– Create methods from Interaction diagrams
From DCD to Java class
public class SalesLineItem
{
private int quantity;
ProductDescription
SalesLineItem
description description : Text
quantity : Integer price : Money
1 itemID : ItemID
getSubtotal() : Money
...
Fig. 20.1
From Interaction diagram to method
{
ProductDescription desc = catalog.ProductDescription(id);
currentSale.makeLineItem(desc, qty);
}
1: desc := getProductDescription(id)
:Product
Catalog
Fig. 20.4
Collection classes
What collection class has been added to the design and why?
Sale
public class Sale
{ isComplete : Boolean
... time : DateTime SalesLineItem
lineItems
private List lineItems = new ArrayList(); becomeComplete() quantity : Integer
1..*
} makeLineItem()
getSubtotal()
makePayment()
getTtotal()
Fig. 20.5
Exception handling
Why is it wise to consider large-scale
exception handling strategies during
design modeling?
In UML, exceptions can be inserted as
property strings of messages
Why implement from least-coupled
7
to most-coupled?
Store
address : Address
1 2
name : Text
3 ProductDescription
ProductCatalog
addSale(...)
description : Text
... price : Money
1 1..* itemID : ItemID
getProductDesc(...)
...
1
1 Sale
5
6
Register isComplete : Boolean 4
time : DateTime SalesLineItem
...
becomeComplete() quantity : Integer
endSale() 1 1..*
makeLineItem(...)
enterItem(...) getSubtotal()
makePayment(...)
makeNewSale()
getTotal()
makePayment(...)
...
1
* Payment
amount : Money
1
Fig. 20.7 ...