Object Design & Mapping
onto Code
By Dr. Maryam Kausar
Object Design
• Purpose of object design:
• Prepare for the implementation of the analysis model based on
system design decisions
• Transform analysis and system design models
• Investigate alternative ways to implement the analysis model
• Use design goals: minimize execution time, memory and other
measures of cost.
• Object Design serves as the basis of implementation
1-2
Terminology: Naming of Design
Activities
1-3
System Development as a Set of
Activities
1-4
1-5
1-6
Object Design consists of 4
Activities
1. Reuse: Identification of existing solutions
• Use of inheritance
• Off-the-shelf components and additional solution objects
• Design patterns
2. Interface specification
• Describes precisely each class interface
3. Object model restructuring
• Transforms the object design model to improve its understandability and
extensibility
4. Object model optimization
• Transforms the object design model to address performance criteria such as
response time or memory utilization.
1-7
1-8
1-9
One Way to do Object Design
• Identify the missing components in the design gap
• Make a build or buy decision to obtain the missing component
• => Component-Based Software Engineering:
• The design gap is filled with available components (“0 % coding”).
1-10
1-11
Design to Code
Mapping
1-12
Creating Class Definitions
1-13
Creating Methods from
Interaction Diagrams
1-14
Collections
• One-to-many relationships are common.
• For example, a Sale must maintain visibility to a group of many
SalesLineItem instances.
• In OO programming languages, these relationships are usually
implemented with the introduction of a collection object, such as
a List or Map, or even a simple array.
• Java libraries contain collection classes such as ArrayList and
HashMap, which implement the List and Map interfaces,
respectively.
1-15
Collections
1-16
Order of Implementation
• Classes need to be implemented from least-coupled to most-
coupled.
• E.g.,
• possible first classes to implement are either Payment or
ProductDescription;
• next are classes only dependent on the prior implementations—
ProductCatalog or SalesLineItem
1-17
1-18
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
Activity
1-19
1-20

5-Oject Design & Mapping on Code__ .pptx

  • 1.
    Object Design &Mapping onto Code By Dr. Maryam Kausar
  • 2.
    Object Design • Purposeof object design: • Prepare for the implementation of the analysis model based on system design decisions • Transform analysis and system design models • Investigate alternative ways to implement the analysis model • Use design goals: minimize execution time, memory and other measures of cost. • Object Design serves as the basis of implementation 1-2
  • 3.
    Terminology: Naming ofDesign Activities 1-3
  • 4.
    System Development asa Set of Activities 1-4
  • 5.
  • 6.
  • 7.
    Object Design consistsof 4 Activities 1. Reuse: Identification of existing solutions • Use of inheritance • Off-the-shelf components and additional solution objects • Design patterns 2. Interface specification • Describes precisely each class interface 3. Object model restructuring • Transforms the object design model to improve its understandability and extensibility 4. Object model optimization • Transforms the object design model to address performance criteria such as response time or memory utilization. 1-7
  • 8.
  • 9.
  • 10.
    One Way todo Object Design • Identify the missing components in the design gap • Make a build or buy decision to obtain the missing component • => Component-Based Software Engineering: • The design gap is filled with available components (“0 % coding”). 1-10
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
    Collections • One-to-many relationshipsare common. • For example, a Sale must maintain visibility to a group of many SalesLineItem instances. • In OO programming languages, these relationships are usually implemented with the introduction of a collection object, such as a List or Map, or even a simple array. • Java libraries contain collection classes such as ArrayList and HashMap, which implement the List and Map interfaces, respectively. 1-15
  • 16.
  • 17.
    Order of Implementation •Classes need to be implemented from least-coupled to most- coupled. • E.g., • possible first classes to implement are either Payment or ProductDescription; • next are classes only dependent on the prior implementations— ProductCatalog or SalesLineItem 1-17
  • 18.
    1-18 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
  • 19.
  • 20.