CSC 330 Object-Oriented Software Design REUSABILITY

Similar documents
Object-Oriented and Classical Software Engineering

Object-Oriented and Classical Software Engineering REUSABILITY AND PORTABILITY 11/5/2017. CHAPTER 8 Slide 8.2. Stephen R. Schach. Overview Slide 8.

IS 0020 Program Design and Software Tools

Fig. 9.1 Fig. 9.2 Fig. 9.3 Fig. 9.4 Fig. 9.5 Fig. 9.6 Fig. 9.7 Fig. 9.8 Fig. 9.9 Fig Fig. 9.11

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Inheritance and Overloading. Week 11

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Programming, numerics and optimization

Introduction to C++ Introduction to C++ Dr Alex Martin 2013 Slide 1

Object Oriented Programming

Documentation. Programming / Documentation Slide 42

10. Abstract Data Types

CS304 Object Oriented Programming

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

What are the characteristics of Object Oriented programming language?

Inheritance, and Polymorphism.

PROGRAMMING IN C++ COURSE CONTENT

Other Topics. Objectives. In this chapter you ll:

Object Oriented Programming. Solved MCQs - Part 2

CPSC 427: Object-Oriented Programming

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

Preview 9/20/2017. Object Oriented Programing with C++ Object Oriented Programing with C++ Object Oriented Programing with C++

Information System Design (IT60105)

CS105 C++ Lecture 7. More on Classes, Inheritance

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING

Objectives. INHERITANCE - Part 1. Using inheritance to promote software reusability. OOP Major Capabilities. When using Inheritance?

INHERITANCE - Part 1. CSC 330 OO Software Design 1


CS304 Object Oriented Programming Final Term

Data Structures using OOP C++ Lecture 3

The University Of Michigan. EECS402 Lecture 06. Andrew M. Morgan. Savitch Ch. 6 Intro To OOP Classes Objects ADTs.

Object-Oriented Design (OOD) and C++

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

COMS W3101 Programming Language: C++ (Fall 2016) Ramana Isukapalli

Data Abstraction. Hwansoo Han

END TERM EXAMINATION

Object Oriented Programming. Java-Lecture 11 Polymorphism

Java Object Oriented Design. CSC207 Fall 2014


ECE 3574: Dynamic Polymorphism using Inheritance

Evolution of Programming Languages

COEN244: Polymorphism

G Programming Languages - Fall 2012

Chapter 5 Object-Oriented Programming

From Module To Objects

VALLIAMMAI ENGINEERING COLLEGE

CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC

Object Oriented Paradigm

Object Oriented Programming. C++ 6 th Sem, A Div Ms. Mouna M. Naravani

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING OBJECT ORIENTED PROGRAMMING CLASS : THIRD SEMESTER CSE

Introduction to Computers and Programming Languages. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

What is Polymorphism? Quotes from Deitel & Deitel s. Why polymorphism? How? How? Polymorphism Part 1

INHERITANCE - Part 1. CSC 330 OO Software Design 1

Chapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language

Object Oriented Programming in C++ Basics of OOP

Object-Oriented Programming (OOP) Fundamental Principles of OOP

Polymorphism Part 1 1

Programming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017

Where do we go from here?

CMSC 4023 Chapter 11

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING

JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)

Computer Science (330)

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Get Unique study materials from

CS250 Final Review Questions

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Object-Oriented Software Engineering. Chapter 2: Review of Object Orientation

Fast Introduction to Object Oriented Programming and C++

JAVA MOCK TEST JAVA MOCK TEST II

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Object Oriented Programming with c++ Question Bank

Jayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT

Short Notes of CS201

CSI33 Data Structures

STRUCTURING OF PROGRAM

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

AN OVERVIEW OF C++ 1

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Unit - IV CHAPTER - 13 INTRODUCTION TO OOP WITH C++ Part 1 Choose the best answer

CS201 - Introduction to Programming Glossary By

An Introduction to Object Orientation

FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

Chapter 1: Object-Oriented Programming Using C++

Sri Vidya College of Engineering & Technology

DE70/DC56 OBJECT ORIENTED PROGRAMMING WITH C++ DEC 2014

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

Object Oriented Software Development CIS Today: Object Oriented Analysis

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

JAVA: A Primer. By: Amrita Rajagopal

1. Write two major differences between Object-oriented programming and procedural programming?


COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

Object Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year

Transcription:

1 CSC 330 Object-Oriented Software Design REUSABILITY

Overview 2 Reuse concepts Impediments to reuse Reuse case studies Objects and reuse Reuse during the design and implementation phases Reuse and maintenance Portability Techniques for achieving portability

Reuse Concepts 3 Two types of reuse Accidental reuse» First, product is built» Then, parts put into part database for reuse Planned reuse» First, reusable parts are constructed» Then, products are built using these parts

Why reuse? 4 Minor Reason It is expensive to design, implement, test, and document software Only 15% of new code serves an original purpose (average) Reuse of parts saves» Design costs» Implementation costs» Testing costs» Documentation costs Major Reason Maintenance Maintenance consumes two-thirds of software cost

Raytheon Missile Systems Division 5 Data-processing software Planned reuse of Designs» 6 code templates COBOL code» 3200 reusable modules Reuse rate 60% (1976 1982)

Toshiba Fuchu Works, Tokyo 6 Industrial process control systems Accidental reuse of Specifications Designs Modules Contracts Manuals Standards Reuse rate (1985) 33% design 48% code

NASA Software 7 Ground support system for unmanned spacecraft control Management permitted (but did not encourage) accidental reuse Accidental reuse of Modules Reuse rate (1982) 28% reused unchanged 10% reused with minor changes

GTE Data Services 8 Data-processing software Strongly encouraged by management Cash incentives when module was accepted for reuse Cash incentive when module was reused Accidental reuse of Modules Reuse rate (1988) 15% reused code, $1.5 million saved (est. 1989) 20% reused code (est. 1993) 50% reused code

Hewlett-Packard 9 Implemented in many divisions of the company Software Technology Division Accidental reuse of resource planning software 4.1 faults per KLOC of new code, 0.9 for reused code Overall fault rate decreased 51% Productivity increased 57% Cost $1 million, savings $4.1 million (1983 92)

Hewlett-Packard (contd) 10 San Diego Technical Graphics (STG) Planned reuse of firmware for printers Cost $2.6 million, savings $5.6 million (1987 94) 24% reduction in faults 40% increase in productivity Cost of developing reusable firmware 11% more Cost of reusing it 19% of developing from scratch

European Space Agency 11 Ariane 5 rocket blew up 37 seconds after lift-off Cost: $500 million Reason: attempt to convert 64-but integer into 16- bit unsigned integer, without Ada exception handler On-board computers crashed, so did rocket Conversion was unnecessary Computations on the inertial reference system can stop 9 seconds before lift-off But, if there is a subsequent hold in countdown, it takes several hours to reset the inertial reference system Computations therefore continue 50 seconds into flight

European Space Agency (contd) 12 Cause of problem Ten years before, it was mathematically proven that overflow was impossible on the Ariane 4 Because of performance constraints, conversions that could not lead to overflow were left unprotected Software was used, unchanged and untested, on Ariane 5 But, the assumptions for the Ariane 4 no longer held Lesson Software developed in one context needs to be retested when integrated into another context

Size of Reused Components 13 NASA Most reused components were small Toshiba Many large components were reused GTE Many large components were reused Reason A strong managerial commitment for reuse is needed

Reuse During Design and Implementation 14 Design reuse Library or toolkit Framework Design pattern Software architecture

Library or Toolkit 15 Set of reusable routines Examples: Scientific software GUI class library or toolkit The user is responsible for the control logic (white in figure)

Application Framework 16 Control logic of the design Hot spots (white in figure) Faster than reusing toolkit More of design is reused The logic is usually harder to design than the operations

Design Pattern 17 A solution to a general design problem In the form of a set of interacting classes The classes need to be customized (white in figure)

Widget Generator 18 Tool that uses the set of classes created by the widget generator

Abstract Factory Pattern 19 Abstract classes and abstract (virtual) methods The interfaces between client and program and generator are abstract The application program is uncoupled from the specific operating system

Software Architecture 20 Encompasses a wide variety of design issues, including: Organization in terms of components How those components interact

Reuse of Software Architecture 21 Architecture reuse can lead to large-scale reuse One mechanism: Software product lines Case study: Hewlett-Packard printers (1995 to 1998)» Person-hours to develop firmware decreased by a factor of 4» Time to develop firmware decreased by factor of 3» Reuse has increased to over 70% of components

Reuse and Maintenance 22 Reuse impacts maintenance more than development Assumptions 30% of entire product reused unchanged 10% reused changed Savings during maintenance are nearly 18% Savings during development are about 9.3%

Objects and productivity 23 Reuse achieved Not via modules with functional cohesion, but via objects (informational cohesion) [classes] In general Software costs have decreased Overall quality has improved Large products are essentially collection of smaller products

Difficulties and Problems 24 Learning curve Particularly noticeable with GUI Problems with inheritance New subclass does not affect its superclass But, any change to a superclass affects all its subclasses Subclasses low in the inheritance tree can be huge (inherited attributes) Polymorphism and dynamic binding Maintenance problems were already discussed

Incompatibilities 25 Hardware (disk, tape, characters, parity) Operating system (JCL, virtual memory) Numerical software (word size, Ada) Compiler FORTRAN Pascal COBOL C Ada C++ Java

Why Portability? 26 Difficulties hampering portability One-off software Hardware incompatibility Lifetimes of software, hardware Multiple copy software Portability saves money!

Portability strategies 27 Portable system software Isolate implementation-dependent pieces» UNIX kernel, device-drivers Levels of abstraction» Graphics

Object-Oriented Principles 28 OOP Encapsulation (class) -- Information Hiding -- Separation of Interface and Implementation -- Standardization -- Access Control mechanisms (private /public) Inheritance -- Hierarchy -- Reusability -- Extensibility -- Expressive power -- Reflects many real-world problems Polymorphism -- Many forms of same function -- Virtual functions -- Abstract Base Classes

Why Object-oriented paradigm? 29 Separation of interface and implementation: Any implementation change should not affect user interface. To ease design process: Separation of Design definition, Implementation, Usage through data encapsulation. Software reuse : To allow (1) sharing, (2) upgrades (3) modification using inheritance and polymorphism. Parameterized classes in templates.

From problem to OO solution 30 Identify the objects ( nouns ) in the problem. Define and implement classes to represent the objects. Class name Data members : public, private, (protected) Function members» Service functions (usually public)» Utility functions (usually private)» Predicate functions. Example: warnings, status indicators, error indicators, etc. Write a driver that carries out the interaction among the objects.

Basic syntax : class definition 31 class class_name { public: list of class attributes (variables, types, constants, and so on) that may be accessed by name from outside the class. list of prototypes for each member function that may be accessed by name from outside the class. private: list of class attributes (variables, types, constants, and so on) that are intended to be hidden for reference from outside the class. list of prototypes for each member function intended to be hidden from outside of the class. };

32 Object-Oriented Principles Using inheritance to promote software reusability Use multiple inheritance to derive a class from several base classes

Inheritance 33 Software reusability. Create new (derived) class from existing (base) class or classes. New derived class is to inherit the data members and member functions of a previous defined base class. New derived class can have its own members (attributes and behaviors).

Inheritance 34 In addition, new class can embellish the members (attributes and behaviors) of base class. Derived class can be large, but more specific. Derived class can also be a base class for future derived class. Single inheritance: derived from one base class Multiple inheritance: derived from multiple base classes.

Example Inheritance 35 Inheritance forms tree-hierarchical structure Examples: Shape TwoDimensionalShape ThreeDimensionalShape circle square triangle sphere cube tetrahedron How to define a derived class? This is public inheritance. class TwoDimensionalShape : public Shape { };

Multiple Inheritance 36

Definition of Class Base1 37 class Base1 { public: Base1(int x) { value = x; } int getdata( ) const { return value; } protected: int value; };

Definition of Class Base2 38 class Base2 { public: Base2(char c) { letter = c; } char getdata( ) const {return letter; } protected: char letter; };

Definition of Class Derived 39 // multiple inheritance class Derived : public Base1, public Base2 { friend ostream &operator << (ostream & const Derived &); public: Derived(int, char, double); double getreal( ) const; private: double real; };

Member Function Definitions for Class Derived 40 Derived::Derived(int i, char c, float f) : Base1(i), Base2(c) { real = f; } double Derived::getReal( )const { return real; } ostream &operator<<(ostream &output, const Derived &d) { output << Interger: << d.value << endl << Character: << d.letter << endl << Real number: << d.real; return output; }

Driver for Multiple Inheritance Example 41 int main( ) { Base1 b1( 10 ), *base1ptr = 0; Base2 b2( z ), *base2ptr = 0; Derived d(7, A, 3.5 ); cout<< Object b1 contains integer < b1.getdata() << \nobject b2 contains char << b2.getdata( ) << \nobject d contains:\n << d << \n\n ; cout<< Data members of Derived can be << accessed individually: << \n Integer: << d.base1::getdata( ) << \n Character: << d.base2::getdata( ) << \nreal number: << d.getreal( ) << \n\n ;

Driver for Multiple Inheritance Example 42 } cout << Derived can be treated as an << object of either base class:\n ; base1ptr = &d; cout << base1ptr->getdata( ) yields << base1ptr->getdata( ) << \n ; base2ptr = &d; cout << base2ptr->getdata( ) yields << base2ptr->getdata( ) << endl; return 0;

43 Points to Remember Software Engineering Observations

Software Engineering Observations 44 A derived class cannot directly access private members of its base class.

Software Engineering Observations 45 Suppose we create an object of a derived class where both the base class and the derived class contain objects of other classes. When an object of that derived class is created, first the constructors for the base class member objects execute, then the base-class constructor executes, then the constructors for the derived class member objects execute, then the derived class constructor executes. Destructors are called in the reverse of the order in which their corresponding constructors are called.

Software Engineering Observations 46 In inheritance, base-class constructors are called in the order in which inheritance is specified in the derived-class definition. The order in which the base-class constructors are specified in the derived-class member initializer list does not affect the order of construction.

Software Engineering Observations 47 Creating a derived class does not affect it s base class s source code or object code; the integrity of a base class is preserved by inheritance.

Software Engineering Observations 48 In an object-oriented system, classes are often closely related. Factor out common attributes and behavior and place these in a base class. Then use inheritance to form derived classes.

Software Engineering Observations 49 A derived class contains the attributes and behaviors of its base class. A derived class can also contain additional attributes and behaviors. With inheritance, the base class can be compiled independent of the derived class. Only the derived class s incremental attributes and behaviors need to be compiled to be able to combine these with the base class to form a derived class.

Software Engineering Observations 50 Modifications to a base class do not require derived classes to change as long as the public and protected interfaces to the base class remain unchanged. Derived classes may, however, need to be recompiled.

Software Reusability 51 Focus on use of classes (object oriented programs) make possible general classes that are applicable to other projects Class libraries exist and may be searched for classes which you can use or adapt for your project