0% found this document useful (0 votes)
43 views

11 Mapping Design To Code

This document discusses mapping object-oriented designs to code implementation. It notes that OO development is iterative, with artifacts from OO analysis and design feeding into implementation in a traceable manner. While some tools can generate partial code from UML, programming requires changes from the initial design. The document provides examples of mapping a domain class diagram to a Java class definition and an interaction diagram to a method. It also discusses adding necessary collection classes, considering exception handling strategies during design, and implementing from the least to most coupled classes.

Uploaded by

aishu sill
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

11 Mapping Design To Code

This document discusses mapping object-oriented designs to code implementation. It notes that OO development is iterative, with artifacts from OO analysis and design feeding into implementation in a traceable manner. While some tools can generate partial code from UML, programming requires changes from the initial design. The document provides examples of mapping a domain class diagram to a Java class definition and an interaction diagram to a method. It also discusses adding necessary collection classes, considering exception handling strategies during design, and implementing from the least to most coupled classes.

Uploaded by

aishu sill
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8

Mapping Designs to

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

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;
private ProductDescription description;
public SalesLineItem(ProductDescription desc, int qty) { ... }
public Money getSubtotal() { ... }
}

SalesLineItem
quantity : Integer

ProductDescription
description
1

getSubtotal() : Money

description : Text
price : Money
itemID : ItemID
...

Fig. 20.1

From Interaction diagram to


method
{
}

ProductDescription desc = catalog.ProductDescription(id);


currentSale.makeLineItem(desc, qty);

enterItem(id, qty)

2: makeLineItem(desc, qty)

:Register

1: desc := getProductDescription(id)

:Product
Catalog

Fig. 20.4

:Sale

Collection classes

What collection class has been added to the design and w


public class Sale
{
...
private List lineItems = new ArrayList();
}

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

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 leastcoupled


7 to most-coupled?

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
...

You might also like