© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.1 4. Design Extraction Why Extract Design? Why UML? Interpreting UML Tracks For Extraction Extraction.

Slides:



Advertisements
Similar presentations
UML an overview.
Advertisements

ESE Einführung in Software Engineering 6. Modeling Objects and Classes Prof. O. Nierstrasz.
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
CS 340 UML Class Diagrams. A model is an abstraction of a system, specifying the modeled system from a certain viewpoint and at a certain level of abstraction.
Object-Oriented Analysis and Design
UML – Class Diagrams.
1 © Wolfgang Pelz UML3 UML 3 Notations describe how to use reusable software. Package Component Deployment Node.
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Object-Oriented Databases v OO systems associated with – graphical user interface (GUI) – powerful modeling techniques – advanced data management capabilities.
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a.
Kari R. Schougaard, PhD Stud. Værktøjer og Teknikker, 2006 UNIVERSITY OF AARHUS Department of Computer Science Unified Modeling Language Visual language.
1 © Wolfgang Pelz UML UML Unified Modeling Language.
ESE Einführung in Software Engineering 6. Modeling Objects and Classes Prof. O. Nierstrasz.
UML Class Diagrams: Basic Concepts. Objects –The purpose of class modeling is to describe objects. –An object is a concept, abstraction or thing that.
CSSE501 Object-Oriented Development
Object-Oriented Analysis and Design
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
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.
Software Construction Lecture 5 Class Diagrams. Agenda 2  Topics:  Examples of class diagrams  Navigation, visibility, named associations, and multiplicity.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
1 SAD2 - UML 4 th Lecture Class Diagram in Construction Phase Patterns Case Study Lecturer: Dr Dimitrios Makris
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
4. UML. CPSC 333: Foundations of Software EngineeringJ. Denzinger 4.1. Motivation The Unified Modeling Language tries to integrate older approaches Developed.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
Chapter 16 Applying UML and Patterns Craig Larman
1 Advanced Software Architecture Muhammad Bilal Bashir PhD Scholar (Computer Science) Mohammad Ali Jinnah University.
Fall 2010 CS4310 Requirements Engineering A Brief Review of UML & OO Dr. Guoqiang Hu Department of Computer Science UTEP 1.
© S. Demeyer, S. Ducasse, O. Nierstrasz Design Extraction.1 4. Design Extraction Design is not code with boxes and arrows Design extraction is not trivial.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
NJIT UML Class Diagrams Chapter 16 Applying UML and Patterns Craig Larman.
An Introduction to the Unified Modeling Language
UML The Unified Modeling Language A Practical Introduction Al-Ayham Saleh Aleppo University
Week III  Recap from Last Week Review Classes Review Domain Model for EU-Bid & EU-Lease Aggregation Example (Reservation) Attribute Properties.
Unified Modeling Language. Object Oriented Methods ► What are object-oriented (OO) methods?  OO methods provide a set of techniques for analyzing, decomposing,
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis and Design Class and Object Diagrams.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Object Oriented Programming
® A Proposed UML Profile For EXPRESS David Price Seattle ISO STEP Meeting October 2004.
OOP Review CS 124.
Chapter 16: UML Class Diagrams
Chapter 16 UML Class Diagrams 1CS6359 Fall 2012 John Cole.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
CSCI 3428: Software Engineering Tami Meredith UML Unified Modeling Language.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Session 1 What Is the UML? Written by Thomas A. Pender Published by Wiley Publishing, Inc. October 5, 2011 Presented by Kang-Pyo Lee.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
1 Object-Oriented Reengineering © S. Demeyer, S.Ducasse, O. Nierstrasz Lecture 4 Radu Marinescu Design Extraction.
Class Diagrams Revisited. Parameterized Classes Parameterized Classes - are used to represent relationships between templates.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
1 Inheritance One of the goals of object oriented programming is code reuse. Inheritance is one mechanism for accomplishing code reuse. It allows us to.
Unified Modeling Language (UML)
Object-Oriented Modeling with UML
Chapter 11 Object-Oriented Design
Design Class Diagrams
UML Class Diagrams: Basic Concepts
Object Oriented Analysis and Design
Object-Oriented Design
Chapter 20 Object-Oriented Analysis and Design
Object Oriented System Design Class Diagrams
Presentation transcript:

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.1 4. Design Extraction Why Extract Design? Why UML? Interpreting UML Tracks For Extraction Extraction of Intention Extraction For The Reusers

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.2 The Reengineering Life-Cycle Requirements Designs Code (0) requirement analysis (1) model capture (2a) problem detection (3) problem resolution (4) Code Transformation (1) model capture (2) reverse engineering issues Scale Beyond boxes and arrows (2b) Reverse Engineering

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.3 Why is Design Extraction Needed? Documentation inexistent, obsolete, or too verbose Abstraction needed to understand applications Original programmers left Only the code available Why UML?  Standard  Communication based on a common language  Can support documentation if we are precise about its interpretation  Extensible

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.4 Design Extraction Design is not code with boxes and arrows Design extraction is not trivial  If you are serious about it, not a low level task! Design extraction should scale up Design extraction can be supported by computers but not fully automated A critical view on hype: “we read your code and generate design documents” Fertilize you with some basic techniques that may help you Show that UML is not that simple and clear but still useful

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.5 UML (Unified Modelling Language) Successor of OOAD&D methods of late 80 & early 90 Unifies Booch, Rumbaugh (OMT) and Jacobson [Booc98a] [Rumb99a]. Currently standardized by OMG. UML is a modelling language and not a methodology (no process) UML defines  a notation (the syntax of the modelling language)  a meta-model (eMof in UML 2.0) — a model that defines the “semantics” of a model  what is well-formed, defined in itself but weakly! Provider -x -y - sety(val) +bump()

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.6 Roadmap Why Extract Design? Why UML? Interpreting UML Tracks For Extraction Extraction of Intention Extraction For The Reusers

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.7 Three Essential Questions When we extract design we should be precise about:  What are we talking about? Design or implementation?  What are the conventions of interpretation that we are applying?  What is our goal: documentation for programmers, for framework users, high- level views, essence, contracts?

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.8 Interpreting UML UML purists do not propose different levels of interpretation, they refer to the UML semantics! Levels of interpretations are not part of UML but they are necessary! What is the sense of representing subclassing using generalization? So at a minimum we should have:  Clear level of interpretation + Clear conventions + Clear goal + UML extensions: stereotypes

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.9 Levels of Interpretations: Perspectives M. Fowler proposed 3 levels of interpretations called perspectives [Fowl97a]:  Conceptual: we draw a diagram that represents the concepts that are somehow related to the classes but there is often no direct mapping.  Specification: we are looking at interfaces of object not implementation, types rather than classes. Types represent interfaces that may have many implementations  Implementation: implementation classes

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.10 Attributes in Perspectives Syntax:  visibility attributeName: attributeType = defaultValue  E.g.: +name: String Conceptual:  Customer name  Customer has a name Specification:  Customer class should provide a way to set and query the name Implementation:  Customer has an attribute that represents its name Possible Refinements: Attribute Qualification  Immutable: Value never change  Read-only: Client cannot change it

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.11 Operations in Perspectives Syntax:  visibility name (parameter-list):return-type  E.g.: + public, # protected, - private Conceptual:  principal functionality of the object. It is often described as a sentence Specification:  public methods on a type Implementation: methods  Operations approximate methods but are more like abstract methods Possible Refinements: Method qualification:  Query (does not change the state of an object)  Cache (does cache the result of a computation), Derived Value (depends on the value of other values), Getter, Setter

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.12 Associations: Conceptual Perspective Associations represent conceptual relationships between classes  An Order has to come from a single Customer.  A Customer may make several Orders.  Each Order has several OrderLines that refers to a single Product.  A single Product may be referred to by several OrderLines.

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.13 Associations: Specification Perspective Associations represent responsibilities Implications:  One or more methods of Customer should tell what Orders a given Customer has made.  Methods within Order will let me know which Customer placed a given Order and what Line Items compose an Order Associations also imply responsibilities for updating the relationship, such as:  specifying the Customer in the constructor for the Order  add/removeOrder methods associated with Customer

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.14 No arrow = navigability in both directions or unknown Conceptual perspective: Orders know Customers but not inverse Specification perspective: responsibility  an Order has the responsibility to identify their Customer but Customer don’t have to identify their orders Implementation perspective:  an Order points to a Customer, but a Customer doesn’t point to its Orders Arrows: Navigability

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.15 Generalization UML semantics only supports generalization and not inheritance. Conceptual:  What is true for an instance of a superclass is true for a subclass (associations, attributes, operations).  Corporate Customer is a Customer Specifications:  Interface of a subtype must include all elements from the interface of a superclass. Implementation:  Generalization semantics is not inheritance. But we should interpret it this way for representing extracted code.

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.16 Need for a Clear Mapping UML  language independent even if influenced by C++  fuzzy (navigability, package...) We should define how we interpret it Define some conventions Some C++ examples: Board board() Board& operator =(const Board& other) throw (const char*); board(): Board Piece* myMap;myMap: Piece class Gomoku: public Boardgame { …«public inherits» static int width();width:Integer

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.17 Private you said?! Which one? Is it class-based (C++) or instance-based (Smalltalk)? in C++:  any public member is visible anywhere in the program  a private member may be used only by the class that defines it  a protected member may be used by the class that defines it or its subclasses  Class-based private in Smalltalk:  instance variables C++ protected, methods are public In Java:  a protected member may be accessed by subclasses but also by any other classes in the same package as the owing class  protected is more public than package

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.18 Language Impact on Extraction Attribute interpretation In C++  Piece* myPiece  aggregation or association Piece& my Piece  aggregation or association Piece myPiece  composition (copied so not shared) In Smalltalk and Java Aggregation and composition are not easy to extract Piece myPiece  attribute or association or aggregation

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.19 Stereotypes: To Represent Conventions! Mechanism to specialize the semantics of the UML elements New properties are added to an element When a concept is missing or does not fit your needs select a close element and extend it 40 predefined stereotypes (c = class, r = relation, o = operation, a = attribute, d = dependency, g = generalization): metaclass (c), instance (r), implementation class (c) constructor (o), destructor(o), friend (d), inherits (g), interface (c), private (g), query (o), subclass (g), subtype (g), Do not push stereotypes to the limit or you will lose standards

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.20 Roadmap Why Extract Design? Why UML? Interpreting UML Tracks For Extraction Extraction of Intention Extraction For The Reusers

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.21 Design is not code with boxes

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.22 Association Extractions (i) Goal: Explicit references to domain classes Domain Objects  Qualify as attributes only implementation attributes that are not related to domain objects.  Value objects  attributes and not associations,  Object by references  associations E.g.: String name  an attribute Order order  an association Piece myPiece (in C++)  composition Define your own conventions  E.g.: integer x integer  point attribute Two classes possessing attributes on each other  an association with navigability at both ends

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.23 Convention Based Association Extraction Filtering based coding conventions or visibility In Java, C++ filter out private attributes  _* In Smalltalk depending on coding practices you may filter out  attributes  that have accessors and are not accessed into subclasses.  with name: *Cache.  attributes that are only used by private methods. If there are some coding conventions class Order { public Customer customer(); // single value public Enumerator orderLines(); // multi-values }

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.24 Operation Extraction You may not extract  accessors  operators, non-public methods,  simple instance creation methods (new in Smalltalk, constructor with no parameters in Java)  methods already defined in superclass,  methods already defined in superclass that are not abstract  methods that are responsible for the initialization, printing of the objects Use company conventions to filter  Access to database, Calls for the UI, Naming patterns

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.25 Operation Extraction (ii) If there are several methods with more or less the same intent  if you want to know that the functionality exists not all the details  select the method with the smallest prefix If you want to know all the possibilities but not all the ways you can invoke them  select the method with the most parameters If you want to focus on important methods  categorize methods according to the number of times they are referenced by clients  a hook method is not often called but is still important What is important to show: the creation interface  Smalltalk class methods in ‘instance creation’ category,  Non default constructors in Java or C++

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.26 Roadmap Why Extract Design? Why UML? Interpreting UML Tracks For Extraction Extraction of Intention Extraction For The Reusers

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.27 Design Patterns Design Patterns reveal the intent so they are definitely appealing for supporting documentation [John92a] [Oden97a] But  Difficult to identify design patterns from the code [Brow96c, Wuyt98a, Prec98a]  What is the difference between a State and a Strategy from the code point of view?  Need somebody who knows  Read the Code in one Hour  Lack of support for code annotation so difficult to keep the use of patterns and the code evolution [Flor97a]

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.28 Roadmap Why Extract Design? Why UML? Interpreting UML Tracks For Extraction Extraction of Intention Extraction For The Reusers

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.29 domain application change propagation Evolution Impact Analysis: Reuse Contract How to identify the impact of changes? How to document for reusers/extenders? How to document framework?

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.30 Example

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.31 Reuse Contracts: General Idea Reuse Contracts [Stey96a] propose a methodology to:  specify and qualify extensions  specify evolution  detect conflicts

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.32 Example Extend UML to specify which other methods a method invokes (reuse contracts) In class Set  + addAll: (c Collection): Collection {invokes add}

© S. Demeyer, S. Ducasse, O. NierstraszDesign Extraction.33 Lessons Learned You should be clear about:  Your goal (detailed or architectural design)  Conventions, like navigability,  Language mapping based on stereotypes  Level of interpretations For Future Development  Emphasize literate programming approach  Xunit-like approaches  Extract design to keep it synchronized UML as Support for Design Extraction  Often fuzzy  Do not support well dynamic/reflective languages  But UML is extensible, so define your own stereotype!