Mapping Models to Code. We will skip most of this chapter –It deals with how to go from UML class diagrams to actual code –You should already have a pretty.

Slides:



Advertisements
Similar presentations
Chapter 9 Technicalities: Classes, etc. Bjarne Stroustrup
Advertisements

And so to Code. Forward, Reverse, and Round-Trip Engineering Forward Engineering Reverse Engineering Round-Trip Engineering.
CS18000: Problem Solving and Object-Oriented Programming.
CSCE 431: From Models to Implementation Some material from Bruegge, Dutoit.
Inheritance Inheritance Reserved word protected Reserved word super
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 Chapter 10, Mapping Models to Code.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
CPSC150 Abstract Classes and Interfaces Chapter 10.
Implementation Goals: “map” design to clean, efficient code Document any design changes found to be useful Produce code that is correct, modular, understandable,
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
1 CS1001 Lecture Overview Object Oriented Design Object Oriented Design.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Code.
Abstract Classes and Interfaces
Interfaces besides classes, Java recognizes another type, an interface interface is used to completely shield off all implementation from the programmer.
Unified Modeling Language
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Code.
1 Web Based Programming Section 6 James King 12 August 2003.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
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.
CSC 142 B 1 CSC 142 Java objects: a first view [Reading: chapters 1 & 2]
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 3.0.
Putting together a complete system Chapter 10. Overview  Design a modest but complete system  A collection of objects work together to solve a problem.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 4, Requirements Elicitation.
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.
Refactoring1 Improving the structure of existing code.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 9, Object Design: Specifying Interfaces.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Relational Schema.
CSC 142 B 1 CSC 142 Java objects: a first view [Reading: chapters 1 & 2]
Software Construction and Evolution - CSSE 375 Making Method Calls Simpler Shawn and Steve Below – “Be the character!” The late acting teacher Lee Strasberg.
1 Software Maintenance and Evolution CSSE 575: Session 3, Part 3 Dealing with Generalization Steve Chenoweth Office Phone: (812) Cell: (937)
Falak Nawaz Mapping Models to Code. Object Model activities 1. Reuse: Identification of existing solutions  Use of inheritance  Off-the-shelf components.
Ivar Jacobson, Grady Booch, and James Rumbaugh The Unified Software Development Process Addison Wesley, : James Rumbaugh's OOMD 1992: Ivar Jacobson's.
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
Refactoring1 Improving the structure of existing code.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 10, Mapping Models to Code.
Today’s lecture Review of chapter 8 Go over examples.
(c) University of Washington10-1 CSC 143 Java Errors and Exceptions Reading: Ch. 15.
Lecture 3: More on Classes Textbook: Chapter 2 Recap: –Classes vs. Objects –Q: What comes first a class or an object? –Q: Do we need a class to create.
Module 9. Dealing with Generalization Course: Refactoring.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
CHAPTER 18 C – C++ Section 1: Exceptions. Error Handling with Exceptions Forces you to defend yourself Separates error handling code from the source.
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
COP 3330 Notes 4/13. Today’s Topics UML Class Diagrams.
State of the Art: Model-based Software Engineering
Chapter 10, Mapping Models to Relational Schema
Lecture 8 D&D Chapter 9 Inheritance Date.
Module Road Map Refactoring Why Refactoring? Examples
Chapter 6: Structured Vs. Object Oriented Analysis and Design.
Chapter 10, Mapping Models to Code
Component Implementations Using RESOLVE
Chapter 10, Mapping Models to Code
Chapter 10, Mapping Models to Code
Patterns of Interaction 2: Publish-Subscribe
Introduction to Classes and Objects
CSCE 606: From Models to Implementation
Overview of Eclipse Lectures
Chapter 10, Mapping Models to Relational Schema
Java objects: a first view
Advance Software Engineering (CEN-5011)
Presentation transcript:

Mapping Models to Code

We will skip most of this chapter –It deals with how to go from UML class diagrams to actual code –You should already have a pretty good idea how to do this Would be trickier if using a language that doesn’t support OOP for example Overview –Mappings are transformations that aim at improving one aspect of the model while preserving functionality. Activities: Optimization Realizing associations Contracts to exceptions Class models to storage schema

Transformations Source code space Forward engineering Refactoring Reverse engineering Model space Model transformation

Model Transformation Example Object design model before transformation Object design model after transformation: Advertiser + Address Player + Address LeagueOwner + Address PlayerAdvertiserLeagueOwner User + Address

Refactoring Example: Pull Up Field public class Player { private String ; //... } public class LeagueOwner { private String ; //... } public class Advertiser { private String _address; //... } public class User { private String ; } public class Player extends User { //... } public class LeagueOwner extends User { //... } public class Advertiser extends User { //... }

Refactoring Example: Pull Up Constructor Body public class User { private String ; } public class Player extends User { public Player(String ) { this. = ; } public class LeagueOwner extends User{ public LeagueOwner(String ) { this. = ; } public class Advertiser extendsUser{ public Advertiser(String ) { this. = ; } public class User { public User(String ) { this. = ; } public class Player extends User { public Player(String ) { super( ); } public class LeagueOwner extends User { public LeagueOwner(String ) { super( ); } public class Advertiser extends User { public Advertiser(String ) { super( ); }

Forward Engineering Example public class User { private String ; public String get () { return ; } public void set (String value){ = value; } public void notify(String msg) { //.... } /* Other methods omitted */ } public class LeagueOwner extends User { private int maxNumLeagues; public int getMaxNumLeagues() { return maxNumLeagues; } public void setMaxNumLeagues (int value) { maxNumLeagues = value; } /* Other methods omitted */ } User LeagueOwner +maxNumLeagues:int Object design model before transformation Source code after transformation + String +notify(msg:String)

Transformation Principles Each transformation must address a single criteria –Transformation should focus on a single design goal and not try to optimize multiple criteria (can lead to errors) Each transformation must be local –A transformation should change only a few methods or classes at once –If an interface changes then the client classes should be changed now too (keep older method around for background compatibility testing) –If you are changing many subsystems at once you are performing an architectural change

Transformation Principles Each transformation must be applied in isolation to other changes –To localize changes transformations should be applied one at a time –E.g. if improving performance of a method, don’t add new functionality at the same time Each transformation must be followed by a validation step –Validate the changes for errors –Update appropriate UML diagrams –Write new test cases to exercise new source code