Mapping Activities Done By: Sara Al-Khulaifi 11/12/2005.

Slides:



Advertisements
Similar presentations
Written by: Dr. JJ Shepherd
Advertisements

CSCE 431: From Models to Implementation Some material from Bruegge, Dutoit.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Art for Chapter 7, Object Design.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
1 Trees Tree nomenclature Implementation strategies Traversals –Depth-first –Breadth-first Implementing binary trees Reading: L&C 9.1 – 9.7.
Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 1 Figure 10-1, Model transformations, refactorings,
Using UML, Patterns, and Java Object-Oriented Software Engineering Art for Chapter 9, Specifying Interfaces.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Code.
Object Design: Specifying Interfaces Chapter 9. 2 Object Design  Object design is the process of adding details to the requirements analysis and making.
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
Lecture 28 More on Exceptions COMP1681 / SE15 Introduction to Programming.
Exception Handling. Background The fact that software modules should be robust enough to work under every situation. The exception handling mechanism.
1 Specifying Object Interfaces. 2 Major tasks in this stage: --are there any missing attributes or operations? --how can we reduce coupling, make interface.
© 2006 Pearson Addison-Wesley. All rights reserved16-1 Methods in the List Interface (Part 1 of 16)
Lecture #4 Agenda Cell phones off & name signs out Review Questions? Objects The birds-and-the-bees talk.
1 CS 426 Senior Projects Chapter 9: Relationships Chapter 10: Inheritance and Polymorphism [Arlow and Neustadt, 2002] February 27, 2007.
Chapter 7, Object Design.
Implementation Goals: “map” design to clean, efficient code Document any design changes found to be useful Produce code that is correct, modular, understandable,
Conquering Complex and Changing Systems Object-Oriented Software Engineering Chapter 7, Object Design.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Code.
Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 1 Object Design  Object design  Detail requirements.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Code.
BCS 2143 Introduction to Object Oriented and Software Development.
Chapter 10, Mapping Models to Code
Single Semester Course or First Semester Questions
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
CSC 520 – Advanced Object Oriented Programming, Fall, 2010 Thursday, September 2, Week 4 Design by Contract, Java Exceptions, Eventing, Finding the Classes,
Implementation Goals: “map” design to clean, efficient code Document any design changes found to be useful Produce code that is correct, modular, understandable,
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Code.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Relational Schema.
(c) University of Washington16-1 CSC 143 Java Linked Lists Reading: Ch. 20.
(c) University of Washington16-1 CSC 143 Java Lists via Links Reading: Ch. 23.
Falak Nawaz Mapping Models to Code. Object Model activities 1. Reuse: Identification of existing solutions  Use of inheritance  Off-the-shelf components.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
March 1, 2004CS WPI1 CS 509 Design of Software Systems Lecture #6 Monday, March 1, 2004.
CEN Tenth Lecture Introduction to Software Engineering (CEN-4010) Mapping Models to Code Instructor: Masoud Sadjadi
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Code.
Introduction to Collections. Collections Collections provide a way of organizing related data in a model Different types of collections have different.
Written by: Dr. JJ Shepherd
Object-Oriented Design Concepts University of Sunderland.
CEN th Lecture Advance Software Engineering (CEN-5011) Instructor: Masoud Sadjadi Object Design: Specifying.
Interpreting the Object Constraint Presented by: Ed Kausmeyer.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 10: Programming Exceptionally.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
UML Fundamental Elements. Structural Elements Represent abstractions in our system. Elements that encapsulate the system's set of behaviors. Structural.
Class Design. Class Design The analysis phase determines what the implementation must do, and the system design.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
State of the Art: Model-based Software Engineering
Chapter 10, Mapping Models to Relational Schema
Chapter 10, Mapping Models to Code
Chapter 10, Mapping Models to Code
Chapter 10, Mapping Models to Code
Chapter 9, Object Design: Specifying Interfaces
CSCE 606: From Models to Implementation
SWE 332 Last Modified Spring 2010 Paul Ammann
Specifying Object Interfaces
Call Class Class User Realize Class Developer Class Implementor
Object Design Object design is the process of adding details to the requirements analysis and making implementation decisions The object designer must.
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
CMSC 202 Exceptions.
Advance Software Engineering (CEN-5011)
Presentation transcript:

Mapping Activities Done By: Sara Al-Khulaifi 11/12/2005

Outlines * Introduction *Mapping Activities. -Optimizing the Object Design Model -Mapping Associations -Mapping Contracts to Exceptions -Mapping Object Models to Tables *Conclusion

Introduction We need a selection of transformations to illustrate a disciplined approach to implementation to avoid system degradation. Object Design System Design Implementation

Mapping Activities Optimizing the Object Design Model Mapping Associations Mapping Contracts to Exceptions Mapping Object Models to Tables

Optimizing the Object Design Model *Direct translation of an analysis model into source code is often inefficient. *During object design, we transfer object model to meet the design goals identified during system design.

Common Optimizations: 1. Adding associations to optimize access paths. 2. Collapsing objects into attributes. 3. Delaying expensive computations. 4. Caching the results of expensive computations.

Optimizing Access paths “ Common sources of inefficiency are: *Repeated association traversals. *”Many” associations. *Misplaced attributes.”

Collapsing an object without interesting behavior PersonSocialSecurity number:String Person SSN:String Object design model before transformation Object design model after transformation ?

Delaying expensive computations Object design model before transformation Object design model after transformation Image filename:String paint() data:byte[] Image filename:String RealImage data:byte[] ImageProxy filename:String image paint() ?

Caching the result of expensive computations *Some methods are called many times, but their results are based on values that do not change or change frequently. *Reducing the number of computations required by these methods substantially improve overall response time. *Example: LeagueBoundary.getStatistics()

We had discus Optimizing the Object Design Model  Mapping Associations Mapping Contracts to Exceptions Mapping Object Models to Tables

Mapping Associations to Collections *Associations are UML concepts that denote collections of bidirectional links between two or more objects. *OOPL uses references instead of associations. References are unidirectional and take place between two objects. During object design we realize associations in terms of references.

Implement Associations Strategy for implementing associations : –Be as uniform as possible –Individual decision for each association Example of uniform implementation –1-to-1 association: Role names are treated like attributes in the classes and translate to references –1-to-many association: Translate to Vector

Unidirectional 1-to-1 Association Usually this transformation is automatically applied by the CASE tool in the code model

Bidirectional 1-to-1 Association MapAreaZoomInAction 11 MapAreaZoomInAction -targetMap:MapArea-zoomIn:ZoomInAction +getZoomInAction() +setZoomInAction(action) +getTargetMap() +setTargetMap(map) Object design model before transformation Object design model after transformation

1-to-Many Association LayerLayerElement 1* LayerLayerElement -containedIn:Layer-layerElements:Set +elements() +addElement(le) +getLayer() +setLayer(l) +removeElement(le) Object design model beforetransformation Object design model after transformation

many-to-many association Source code after transformation public class Tournament { private List players; public Tournament() { players = new ArrayList(); } public void addPlayer(Player p) { if (!players.contains(p)) { players.add(p); p.addTournament(this); } public class Player { private List tournaments; public Player() { tournaments = new ArrayList(); } public void addTournament(Tournament t) { if (!tournaments.contains(t)) { tournaments.add(t); t.addPlayer(this); } TournamentPlayer

Qualification Scenario -runs:Hashtable +elements() +addRun(simname,sr:SimulationRun) +removeRun(simname,sr:SimulationRun) SimulationRun -scenarios:Vector +elements() +addScenario(s:Scenario) +removeScenario(s:Scenario) simname 0..1 * Object design model before transformation Object design model after transformation Scenario SimulationRun

Transformation of an association class TournamentPlayer ** Object design model before transformation Object design model after transformation: 1 class and two binary associations Statistics +getAverageStat(name) +getTotalStat(name) +updateStats(match) TournamentPlayer ** 11 Statistics +getAverageStat(name) +getTotalStat(name) + updateStats(match)

Optimizing the Object Design Model Mapping Associations  Mapping Contracts to Exceptions Mapping Object Models to Tables

Mapping Contracts to Exceptions Many object-oriented languages, including Java do not include built-in support for contracts. However, we can use their exception mechanisms as building blocks for signaling and handling contract violations In Java we use the try-throw-catch mechanism Example: –Let us assume the acceptPlayer() operation of TournamentControl is invoked with a player who is already part of the Tournament. –In this case acceptPlayer() should throw an exception of type KnownPlayer.

public class TournamentControl { private Tournament tournament; public void addPlayer(Player p) throws KnownPlayerException { if (tournament.isPlayerAccepted(p)) { throw new KnownPlayerException(p); } //... Normal addPlayer behavior } public class TournamentForm { private TournamentControl control; private ArrayList players; public void processPlayerApplications() { // Go through all the players for (Iteration i = players.iterator(); i.hasNext();) { try { // Delegate to the control object. control.addPlayer((Player)i.next()); } catch (KnownPlayerException e) { // If an exception was caught, log it to the console ErrorConsole.log(e.getMessage()); }

A complete implementation of the Tournament.addPlayer() contract «precondition» !isPlayerAccepted(p) «invariant» getMaxNumPlayers() > 0 «precondition» getNumPlayers() < getMaxNumPlayers() Tournament +isPlayerAccepted(p:Player):boolean +addPlayer(p:Player) +getMaxNumPlayers():int -maxNumPlayers: int +getNumPlayers():int «postcondition» isPlayerAccepted(p)

Simple mapping *Checking Preconditions. *Checking Postconditions. *Checking invariant *Dealing with inheritance. *Coding effort. *Increased opportunities. *Obfuscated code. *Performance drawback.

Optimizing the Object Design Model Mapping Associations Mapping Contracts to Exceptions (*)Mapping Object Models to Tables

Questions: (1) List the four Mapping Activities. (2)What are the common source of inefficiency? (3)What is a reference? And what is a collections? (4)Why do we use Qualified associations? (5)When do we apply check preconditions?

Thanx 4 U’R Attention Sara Al-Khulaifi