11MappingDesigntoCode.ppt ooad software software

kavitamittal18 2 views 8 slides Mar 07, 2025
Slide 1
Slide 1 of 8
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8

About This Presentation

hgjhkhkhkh


Slide Content

Mapping Designs to Mapping Designs to
CodeCode
Larman, Chapter 20Larman, Chapter 20
CSE432CSE432
Object Oriented Software Object Oriented Software
EngineeringEngineering

OO development is iterativeOO development is iterative

OOA/D artifacts feed into implementation OOA/D artifacts feed into implementation
model in a traceable mannermodel in a traceable manner

Some tools generate partial code from UMLSome tools generate partial code from UML

But programming not trivial generation!But programming not trivial generation!

Programmers make changes as the work Programmers make changes as the work
out the detailsout the details

Therefore, Expect and plan for change and Therefore, Expect and plan for change and
deviation from design during programmingdeviation from design during programming

Mapping Designs to CodeMapping Designs to Code

Write source code for:Write source code for:
–Class and interface definitionsClass and interface definitions
–Method definitionsMethod definitions

Work from OOA/D artifactsWork from OOA/D artifacts
–Create class definitions for Domain Class Create class definitions for Domain Class
Diagrams (DCDs)Diagrams (DCDs)
–Create methods from Interaction diagramsCreate methods from Interaction diagrams

From DCD to Java classFrom 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
getSubtotal() : Money
ProductDescription
description : Text
price : Money
itemID : ItemID
...
1
description
Fig. 20.1Fig. 20.1

From Interaction diagram to methodFrom Interaction diagram to method
Fig. 20.4Fig. 20.4
2: makeLineItem(desc, qty)enterItem(id, qty)
1: desc := getProductDescription(id)
:Register :Sale
:Product
Catalog
{
ProductDescription desc = catalog.ProductDescription(id);
currentSale.makeLineItem(desc, qty);
}

Collection classesCollection classes
SalesLineItem
quantity : Integer
getSubtotal()
1..*
Sale
isComplete : Boolean
time : DateTime
becomeComplete()
makeLineItem()
makePayment()
getTtotal()
public class Sale
{
...
private List lineItems = new ArrayList();
}
A collection class is necessary to
maintain attribute visibility to all the
SalesLineItems.
lineItems
Fig. 20.5Fig. 20.5
What collection class has been added to the design and why?

Exception handlingException handling

Why is it wise to consider large-scale Why is it wise to consider large-scale
exception handling strategies during exception handling strategies during
design modeling?design modeling?

In UML, exceptions can be inserted as In UML, exceptions can be inserted as
property strings of messagesproperty strings of messages

Why implement from least-coupled Why implement from least-coupled
to most-coupled?to most-coupled?
SalesLineItem
quantity : Integer
getSubtotal()
ProductCatalog
...
getProductDesc(...)
ProductDescription
description : Text
price : Money
itemID : ItemID
...
Store
address : Address
name : Text
addSale(...)
Payment
amount : Money
...
1..*
1..*
Register
...
endSale()
enterItem(...)
makeNewSale()
makePayment(...)
Sale
isComplete : Boolean
time : DateTime
becomeComplete()
makeLineItem(...)
makePayment(...)
getTotal()
...
1
1
1
1
1
1
*
1
2
3
4
5
6
7
Fig. 20.7Fig. 20.7
Tags