February, 2000Programming Technology Lab, Vrije Universiteit Brussel Component and Framework Reuse Dr. Tom Mens Programming Technology Lab Vrije Universiteit.

Slides:



Advertisements
Similar presentations
Technieken van de Software Architectuur, VUB ‘98-’99, Part 21 Part 2: Component and Framework Reuse Technieken van de Software Architectuur.
Advertisements

1 A Graph Rewriting Formalism for Object-Oriented Software Evolution Tom Mens FWO Postdoctoral Fellow Programming Technology Lab Vrije.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
1 Copyright 1998 by Dragos Manolescu and Joseph W. Yoder Building Frameworks With Patterns “An Active Object-Model For A Dynamic Web-Based Application”
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Stéphane Ducasse2.1 OOP? What is OOP? Why? OOP in a nutshell.
Object-Oriented Analysis and Design
Introduction To System Analysis and Design
1 Software Testing and Quality Assurance Lecture 12 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
7M701 1 Software Engineering Object-oriented Design Sommerville, Ian (2001) Software Engineering, 6 th edition: Chapter 12 )
UML – Class Diagrams.
1 © Wolfgang Pelz UML3 UML 3 Notations describe how to use reusable software. Package Component Deployment Node.
Object Oriented System Development with VB .NET
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
Chapter 10 Class and Method Design
Reuse Activities Selecting Design Patterns and Components
Modelling classes Drawing a Class Diagram. Class diagram First pick the classes –Choose relevant nouns, which have attributes and operations. Find the.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
1 Object-Oriented Software Engineering CIS 375 Bruce R. Maxim UM-Dearborn.
UML and Object Oriented Concepts
Domain Modeling (with Objects). Motivation Programming classes teach – What an object is – How to create objects What is missing – Finding/determining.
Introduction To System Analysis and design
A Survey of Software Refactoring Tom Mens, Tom Tourwé
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Object-oriented Software Engineering with Reuse Contracts Koen De Hondt, Carine Lucas, Kim Mens, Tom Mens, Patrick Steyaert, Roel Wuyts Programming Technology.
Objects and Components. The adaptive organization The competitive environment of businesses continuously changing, and the pace of that change is increasing.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
EMOOSE Object-Oriented Software Evolution Dr. Tom Mens Programming Technology Lab Vrije Universiteit.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
1 Object orientation. 2 What benefits does OO give? Primarily –Encapsulation (Associates data & operations) –Types & specialisation –Software re-use.
Introduction To System Analysis and Design
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Sommerville 2004,Mejia-Alvarez 2009Software Engineering, 7th edition. Chapter 8 Slide 1 System models.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Refactoring Deciding what to make a superclass or interface is difficult. Some of these refactorings are helpful. Some research items include Inheritance.
Kal Bugrara, Ph.DSoftware Engineering Northeastern University Fundamentals Of Software Engineering Lecture V.
1 How to Design Frameworks -- Copyright 2005 by Ralph E. Johnson How to Develop Frameworks Ralph E. Johnson Dept. of Computer Science 1304 W. Springfield.
What is Object-Oriented?  Organization of software as a collection of discreet objects that incorporate both data structure and behavior.
Object-Oriented Data Modeling
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
OBJECT ORIENTED AND FUNCTION ORIENTED DESIGN 1 Chapter 6.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Introduction to Object-Oriented Programming Lesson 2.
Software Reuse Course: # The Johns-Hopkins University Montgomery County Campus Fall 2000 Session 4 Lecture # 3 - September 28, 2004.
Reuse Contracts A Historic Overview Dr. Tom Mens Programming Technology Lab Vrije Universiteit Brussel Course OOSE.RC EMOOSE
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Module 9. Dealing with Generalization Course: Refactoring.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Basic Characteristics of Object-Oriented Systems
ISBN Chapter 12 Support for Object-Oriented Programming.
Class Design. Class Design The analysis phase determines what the implementation must do, and the system design.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
2.2 Framework Techniques.
2.3 Collaboration Contracts
Chapter 11 Object-Oriented Design
Advanced Programming Behnam Hatami Fall 2017.
Object Oriented System Design Class Diagrams
Refactoring.
Presentation transcript:

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Component and Framework Reuse Dr. Tom Mens Programming Technology Lab Vrije Universiteit Brussel Course OOSE.RC EMOOSE

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Goals  Teach about families of related applications (application families)  Teach two basic forms of reuse: component and framework reuse  Teach how to deal with commonalities and variabilities  Teach about the iterative process of building components and frameworks

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Definitions  a component is a system building block defined by its external interface  a system is a set of communicating components fitting together to realise a certain functionality (i.e., end user services)  systems are engineered, well-documented workproducts  an application system is a system delivered outside of the developer organization to offer a coherent set of services to an end user

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Application Families  An application system family is a set of application systems with common features  application systems in a family share certain foundations or are interoperable in some way  application system suite: applications that are intended to work together  e.g., Office Suite  application system variants: share a common foundation  e.g., different OS, different hardware

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Components are the Units of Reuse  A component is a type, class or any other workproduct that has been specifically designed to be reusable  classes, collaborations, use cases, models,...  Designed, packaged and documented to be reusable  components have an external interface  Different reuse mechanisms imply different components  inheritance => class (source code level)  copy&modify reuse => anything  CORBA => class (executable level)

February, 2000Programming Technology Lab, Vrije Universiteit Brussel  Reuse is class centered  Application calls library  Difficult to reuse application logic  Logic is spread among different classes Reuse of Components in Isolation Button Number Complex Application Logic of Calculator Application

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Component Systems  A component system is a system product that offers a set of reusable features.  Features are implemented as related and interconnected sets of components of various types, associated packages and descriptive documents. > LAN Logical View AddressableNode AbstractAddress ActivePacket Packet Forwarding AddressableNode ActivePacket Destination Checking AddressableNode AbstractAddress

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Frameworks are Component Systems  An application framework is a reusable and customisable design for a set of components  typically, classes are components  consists of abstract and concrete classes  emphasises on collaboration between classes  A framework is not necessarily a working application  abstract classes and methods must be “filled in” with concrete ones first  the places where the framework must be “filled in” are called the hot spots

February, 2000Programming Technology Lab, Vrije Universiteit Brussel LAN Framework Addressable Node Active Packet Address PostScript Printer ASCII Printer Hot Spots 3Collaboration contracts 3Templates Counting Packet Broadcast- Packet

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Kinds of Frameworks  Application Frameworks  MacApp  Visualworks  OpenDoc  Domain-Specific Frameworks  ET++ Swapsmanager (financial world)  Intermedia (hypermedia)  OSEFA (manufacturing systems)  Closer to us  Whats’On (television broadcast planning)  ApplFLab (application building)  Conduits (OO Course)

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Range of Component Systems  Classes are used in isolation  Application calls library  No template solution (no hot spots)  Framework as a whole is reused  Framework calls application  Template solution Class LibraryFramework

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Components need to be Specialised before Reuse  Specialisation can be dealt with ‘pro-actively’  what are the foreseen (anticipated) customisations?  use different mechanisms to deal with foreseen customisations  parameterised classes (e.g. C++ templates)  application configuration (e.g. Microsoft Word)  abstract classes and collaboration contracts  Specialisation that must be dealt with ‘after-the-facts’  not all customisations can be foreseen !  use different mechanisms to deal with unforeseen customisations  inheritance of concrete classes  scripting  abstract classes and collaboration contracts

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Foreseen Specialisations: Features  Different application systems and component systems can be distinguished from similar systems on the basis of the functionality, services and many other features they offer.  In general, any distinguishing characteristic can be a feature - “a difference that makes a difference”

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Foreseen Specialisations: Domain Analysis  Scope the domain  Analyse the domain  gather domain knowledge  generalise from existing applications  find things that are given different names but are really the same  parameterise to eliminate differences  break large things into small things so that similar components can be found  Model commonalities and variabilities  analise the commonalities and variabilities of the different applications in terms of features

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Domain Engineering Domain Analysis Domain Design Domain Implementation OOA OOD classification OOP polymorphism 3 Variation points 3 Facades 3 Roles 3 Collaboration Contracts 3 Design Patterns 3 Abstract classes 3 Frameworks

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Application Engineering Domain Analysis Domain Design Domain Implementation Domain Engineering Application Engineering Application Analysis Application Design Application Implementation  application in the family

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Unforeseen Specializations: Refactoring  Refactoring (or restructuring) is a reorganisation of a system to improve reuse  A refactoring is behavior preserving transformation  A refactoring has a precondition  Some refactorings are based on invariants  Refactoring into object-oriented frameworks  iteratively turning an OO application into a framework

February, 2000Programming Technology Lab, Vrije Universiteit Brussel References  William F. Opdyke. Refactoring object-oriented frameworks. PhD Dissertation, University of Illinois at Urbana-Champaign,  Ralph E. Johnson, William F. Opdyke: Refactoring and Aggregation,  William F. Opdyke, Ralph E. Johnson: Creating abstract superclasses by refactoring. Proc. ACM Computer Science Conference, pp , ACM Press,  Don Roberts, John Brant, Ralph E. Johnson. A refactoring tool for Smalltalk. TAPOS Journal 3(4): ,  Martin Fowler. Refactoring: improving the design of existing programs. Addison-Wesley, 1999.

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Generalisations Require Concrete Cases  Abstract classes and frameworks are generalisations  People think concretely, not abstractly  Abstractions are found bottom up, by examining concrete examples first  Generalisation proceeds by:  finding things that are given different names but are really the same (and thus renaming them)  parameterising to eliminate differences  breaking large things into small things so that similar components can be found à Refactoring

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Low-Level Refactorings (1)  Creating a program entity  create empty class  define a new class with no instance variables, nor methods  create instance variable  add an unreferenced instance variable to a class  create method  add a method to a class that either is unreferenced or is identical to an already inherited method  Deleting a program entity  delete unreferenced class  delete unreferenced instance variable  delete methods  delete a set of methods; either each method is redundant, or the only references to it are by other methods that are also being deleted

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Low-Level Refactorings (2)  Changing a program entity  change class name  the precondition ensures distinct class names  change variable name  the name change is reflected throughout its scope  change method name  change the name of a method and any corresponding methods defined in subclasses, and any corresponding message sends  change type (C++)  change the type of a set of (pointer) variables and functions (i.e. change the types of the variables and return types of the functions)  change access control mode  change the access control mode (‘private’, ‘protected’, ‘public’) of a member variable or function

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Exercise  Try to find as much other low-level (behaviour-preserving) refactorings for changing a program entity yourself.

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Low-Level Refactorings (3)  Changing a program entity (cont’d)  add method argument  add a new argument to the definition of a method in its class (and subclasses that override it). In each method invocation, add an argument which is a dynamically created instance  delete method argument  delete an argument from the definition of a method in its class (and subclasses that override it). In each method invocation, the argument is removed  reorder method arguments  reorder the arguments in a method definition in its class (and subclasses that override it) and in all invocations of that method  convert instance variable to pointer (C++)

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Low-Level Refactorings (4)  Changing a program entity (cont’d)  add method body  add a method body to an existing method (signature)  delete method body  delete a method body from an existing method (making it a signature only)  convert variable references to method invocations  convert all references to V to invocations of its (existing!) accessor method. Convert all assignments to V to invocations of its (existing!) mutator method  replace expressions with method invocation  replace a list of expressions in a method with an invocation to a method that behaves the same as the list of expressions

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Low-Level Refactorings (5)  Moving an instance variable  move instance variable to superclass  move instance variable V to class C from all subclasses where it is defined  move instance variable to subclasses  move an instance variable from its current containing class to each of its immediate subclasses  Composite refactorings  abstract access to instance variable  abstract access to an instance variable by defining accessor and mutator methods, and replacing all variable references with invocations of these methods  inline method invocation  replace method invocation with body of invoked method  convert code segment to method  define new method with unique name, whose body is equivalent to an expression list of an existing method. Replace that expression list in the method with an invocation of the new method

February, 2000Programming Technology Lab, Vrije Universiteit Brussel High-level Refactorings: Abstraction concrete class A concrete class B concrete class A abstract class X abstraction

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Abstraction: Refactor to Generalise  Creating an Abstract Superclass  Create a common superclass  Make method signatures compatible  Add method signatures to the superclass  Make method bodies compatible  Make instance variables compatible  Move instance variables to the superclass  Migrate common code to the abstract superclass PrintServer print:Boolean FileServer save OutputServer output PrintServerFileServer

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Refactor to Specialise  Motivation :  improve framework design by decomposing a large, complex class into several smaller classes  the complex class usually embodies both a general abstraction and several different concrete cases that are candidates for specialisation  Specialise a class by adding subclasses corresponding to the conditions in a conditional expression:  choose a conditional whose conditions suggest subclasses (this depends on the desired abstraction)  for each condition, create a subclass with a class invariant that matches the condition  copy the body of the condition to each subclass, and in each class simplify the conditional based on the invariant that is true for the subclass  specialize some (or all) expressions that create instances of the superclass

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Refactor to Specialise: Example Disk... copyDisk formatDisk... Disk Management for MSDOS Disk disktype... copyDisk formatDisk Disk Management for MSDOS+MAC formatDisk self diskType = #MSDOS ifTrue: [.. code1..]. self diskType = #MAC ifTrue: [.. code2..]. Disk... copyDisk formatDisk... Disk Management for MSDOS+MAC Class Invariant MSDOSDisk... copyDisk formatDisk... MACDisk... copyDisk formatDisk...

February, 2000Programming Technology Lab, Vrije Universiteit Brussel High-level Refactorings: Factorisation abstract class A factorisation method m1 method m2 abstract class A method m1 concrete class X method m2

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Refactor to Capture Aggregations & Components  Motivation :  Inheritance is a powerful technique, but in modelling the relationships among classes it is sometimes overused and incorrectly used. Aggregations are another tool for modelling these relationships.  Several refactorings regarding aggregations :  qualify an instance variable as a component  move instance variables/methods from an aggregate class to the class of one of its components  move instance variables/methods from a component class to the aggregate classes that contain components which are instances of the component class  convert a relationship, modelled using inheritance, into an aggregation and vice versa

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Example: Convert Inheritance into Aggregation Matrix MatrixRepresentation TwoDimArraySparseMatrix rep TwoDimArray

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Evolutionary transformations  A refactoring is a transformation that preserves the behaviour of a software artifact  An evolutionary transformation changes the behaviour of a software artifact  Each transformation can be decomposed into a (number of) refactoring(s) and a (number of) evolutionary transformation(s)

February, 2000Programming Technology Lab, Vrije Universiteit Brussel Exercise 1.Give at least three different “pure” evolutionary transformations 2.Give at least three transformations that change the behaviour of a software artifact, and decompose them into a refactoring part and a evolutionary part.