Introduction. Introduction. Introduction

Similar documents
CREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed

COMP200 INHERITANCE. OOP using Java, from slides by Shayan Javed

Inheritance & Polymorphism Recap. Inheritance & Polymorphism 1

Inheritance and Polymorphism

ITI Introduction to Computing II

CS1150 Principles of Computer Science Objects and Classes

Lecture 36: Cloning. Last time: Today: 1. Object 2. Polymorphism and abstract methods 3. Upcasting / downcasting

ITI Introduction to Computing II

Use the scantron sheet to enter the answer to questions (pages 1-6)

Lecture #1. Introduction to Classes and Objects

CMSC 132: Object-Oriented Programming II. Inheritance

In this lab, you will be given the implementation of the classes GeometricObject, Circle, and Rectangle, as shown in the following UML class diagram.

CISC 3115 Modern Programming Techniques Spring 2018 Section TY3 Exam 2 Solutions

Making New instances of Classes

Topic 7: Algebraic Data Types

Chapter 11 Inheritance and Polymorphism. Motivations. Suppose you will define classes to model circles,

Inheritance and Polymorphism

CS-202 Introduction to Object Oriented Programming

Abstract Class. Lecture 21. Based on Slides of Dr. Norazah Yusof

Inheritance Systems. Merchandise. Television Camcorder Shirt Shoe Dress 9.1.1

Chapter 10 Inheritance and Polymorphism. Dr. Hikmat Jaber

IS502052: Enterprise Systems Development Concepts Lab 1: Java Review

CSE 8B Programming Assignments Spring Programming: You will have 5 files all should be located in a dir. named PA3:

CISC 3115 TY3. C09a: Inheritance. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 9/20/2018 CUNY Brooklyn College

Object Oriented Relationships

Reusing Classes. Hendrik Speleers

OBJECT ORİENTATİON ENCAPSULATİON

Inheritance Motivation

Java Object Oriented Design. CSC207 Fall 2014

Inheritance (an intuitive description)

Chapter 9 - Object-Oriented Programming: Polymorphism

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism

Lecture Notes Chapter #9_b Inheritance & Polymorphism

S.O.L.I.D: Software Engineering Principles

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

CS 520 Theory and Practice of Software Engineering Fall 2018

Chapter 6: Inheritance

ITI Introduction to Computing II

ITI Introduction to Computing II

Final Examination Semester 3 / Year 2010

IST311. Advanced Issues in OOP: Inheritance and Polymorphism

F I N A L E X A M I N A T I O N

Constructor. Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.

HAS-A Relationship. If A uses B, then it is an aggregation, stating that B exists independently from A.

Programming 2. Inheritance & Polymorphism

CS 520 Theory and Practice of Software Engineering Fall 2017

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass?

index.pdf January 21,

HAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

CS 320 Introduction to Software Engineering Spring March 06, 2017

Object Oriented Programming. Java-Lecture 11 Polymorphism

Inheritance. OOP: Inheritance 1

CSC207H: Software Design. Java + OOP. CSC207 Winter 2018

COMP200 - Object Oriented Programming: Test One Duration - 60 minutes

Methods Common to all Classes

M301: Software Systems & their Development. Unit 4: Inheritance, Composition and Polymorphism

Chapter 9: A Second Look at Classes and Objects

COMP 250. inheritance (cont.) interfaces abstract classes

Inheritance, Polymorphism, and Interfaces

n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4

CSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community

Inheritance. Finally, the final keyword. A widely example using inheritance. OOP: Inheritance 1

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

CSC9T4: Object Modelling, principles of OO design and implementation

COMP 249: Object Oriented Programming II. Tutorial 2: Intro to Inheritance

The mechanism that allows us to extend the definition of a class without making any physical changes to the existing class is called inheritance.

Aim: How do we find the volume of a figure with a given base? Get Ready: The region R is bounded by the curves. y = x 2 + 1

Inheritance (Deitel chapter 9)

Topics. Topics (Continued) 7.1 Abstract Data Types. Abstraction and Data Types. 7.2 Object-Oriented Programming

System.out.print(); Scanner.nextLine(); String.compareTo();

Programming Assignment Unit 7

Java and OOP. Part 3 Extending classes. OOP in Java : W. Milner 2005 : Slide 1

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

Full file at Chapter 2 - Inheritance and Exception Handling

Outline. Inheritance. Abstract Classes Interfaces. Class Extension Overriding Methods Inheritance and Constructors Polymorphism.

Introduction to Object-Oriented Programming

24. Inheritance. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

Extending Classes (contd.) (Chapter 15) Questions:

Programming Languages and Techniques (CIS120)

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Programming Languages and Techniques (CIS120)

Computer Science II (20073) Week 1: Review and Inheritance

Midterm 2 Grading Key

Lab Exercise#1: In Lab#1 You have written the class called Author which is designed as shown in the class diagram

Ch02. True/False Indicate whether the statement is true or false.

Today. Book-keeping. Inheritance. Subscribe to sipb-iap-java-students. Slides and code at Interfaces.

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2)

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

Inheritance (continued) Inheritance

This page intentionally left blank

CS250 Intro to CS II. Spring CS250 - Intro to CS II 1

22. Inheritance. Java. Summer 2008 Instructor: Dr. Masoud Yaghini

Inheritance (Part 5) Odds and ends

Comments are almost like C++

Inheritance (cont.) COSC346

COS226 - Spring 2018 Class Meeting # 13 March 26, 2018 Inheritance & Polymorphism

6.170 Recitation #5: Subtypes and Inheritance

Abstraction in Software Development

Transcription:

Finding Classes by Execution from an Object-Oriented Class Library Shaochun Xu Young Park Software Reuse? Why Reuse? Component Retrieval Approaches Information Retrieval Methods Descriptive Methods Operational Semantic Methods.. Steps to organize and retrieve components Organizing the component library Formulating the user query Retrieving components from library Browsing the candidates Execution-based retrieval? find relevant components by comparing input and output spaces of components Execute Test program user create Input Desired Class Behavior compare Output Candidate Classes Class Behavior Set Class Library Execution-based retrieval Podgurski & Pierce (1992) proposed behavior retrieval for function components Atkinson & Duke (1995) proposed for OO classes, but without implementation Extended and implemented by Niu (1999) The class library in previous method Public class ObjectEquals{ public boolean equals (Object arg1, Object arg2) { return arg1.equals (arg2); public boolean notequals(object arg1, Object arg2) { return!arg1.equals (arg2); public boolean identical(object arg1, Object arg2) { return arg1==arg2; public boolean identical(object arg1, Object arg2) { return arg1==arg2; 1

Class only perform math calculations, string manipulations, object comparisons Similar to the functions of procedure languages Different from the real world class () (String) Uncaptureable behavior only method calculatesal (int) can be executed () (String) Default constructor can not retrieve those classes with user-defined constructors (String) Order of arguments require user to input the correct argument order This is not practical reduce retrieval recall Method (String, int, boolean) public class C {... public int add (int, String, boolean) {.. Fully consider the real world classes Class definition fields constructors observer methods modifier methods Class N=({F, {C, {O, {M) () (String) Differences among constructor, observer and modifier Types Return Parameters Type value Type value Constructors none none any any Observers Any (except void) Any (except none) none none Modifiers Any (include none) Any (include none) any any 2

Class behavior A set of responses from the class methods based on a test program A complete class behavior is all the responses from all the methods and constructors In order to disclose the complete behavior of a class create an instance (object) update the states (by calling modifier) inspect each state to determine whether it is in the state as expected (by calling observer) Program executing order execute one or more constructors to create some objects with initial states (if no, a default constructor is called) execute zero/more modifier methods to modify the states of the object apply observer methods to the objects. the result returned by the observer are compared with the user s input CM*O+ Message a set of input values and types desired return type and value the type is determined by the message (constructor, observer, modifier) message1{(int, 5), (none, none) message2{(int, 2),(boolean,true),(void, none) message3{(none, none),(int, 2) Test program A set of messages to be sent to the system {[(int, 5)], [(int, 2),(boolean,true)], [(none, none)] with expected behavior {none, none, 2 Type Checking & Run-time storage Store the info during first time For each constructor if (it is the first constructor) load class from the library stored constructor info if (arglist==parameterlist) execute constructor else skip 3

Type Checking & Run-time storage For each method if (it is the first method) load class from the library stored method info if (arglist==parameterlist && return types matches) execute method else skip Retrieval regardless of argument order message {(int, 5), (String, li ), (float, 6.0), (none, none) (int, String, float) (int, float, String) (String, float, int) (String, int, float) (float, String, int) (float, int, String) Recursively execution on these compositions Matching process and candidate classes A match is found, if the message and the method have: the same type (constructor, observer, and modifier) the same number of arguments and convertible types the same or convertible return types the same or tolerable return values Matching process and candidate classes Matching algorithm for each test message if (it is constructor) if (argument list matches parameterlist in each constructor) construct the instance return true else return false Else //it is method if (the return types match) if (check each case of argument list with parameter list of each method) if (there is no instance) call default constructor executes on the method if (result same as the expected) return true return false else return false Matching process and candidate classes Candidates classes matches info stored in a vector associated with the class name classes with at least 1 match display the candidates (the most match class comes first) 4

Inheritance, Overloading and Overriding Product Inheritance subclass and superclass inherited methods should be executed and counted if the match is found Id : String price : float Product () Product (String, String, float, String) setid (String) : void setname (String) : void setprice (float) : void getid () : String getname () : String getprice () : float calprice (int) : float cpu : int Computer Computer (String, float, String) setcpu (int) : void getcpu () : int calprice (int) : float calprice (int, String, float) : float Inheritance, Overloading and Overriding Overloading Selection of the actual method is based on the type matching between arguments of messages and parameter of methods Do not need to take care specially Overriding overriding method and overridden method overriding method does not cause side effect overridden method is hidden from the subclass Browse the Candidates Directly browse the code (implementation) is practical and useful Class library is small scale Candidate classes are not too many Implementation Main Interface Implementation Input interface for observer method Implementation Retrieval Interface 5

(abstract) Shape name : string An Example of Library Shape () Shape (String) {abstract area () : double lessthan (Shape) : boolean A class library contains 7 classes Geometry related classes: Shape, Circle, Triangle, Rectangle, Equilateral, Isosceles and Square They are related. Circle radius : double Circle () Circle (String, double) area () : double getradius () : double setradius (double) : void Triangle side1 : double side2 : double side3 : double Triangle () Triangle (double, double, double, String) area () : double getsidecount () : int getside1 () : double getside2 () : double getside3 () : double Rectangle length : double width : double Equilateral () Equilateral (double, double, String) area () : double setlength (double) : void setwidth (double) : void getlength () : double getwidth () : double tostring () : double Isosceles Isosceles (double, double, string) setside (double) : void setbase (double) : void getside () : double getbase () : double Equilateral Equilateral (double, String) setside (double) : void getside (double) : double tostring () : double Square Square (double, String) setside (double) : void getside () : double Conclusions An execution-based class retrieval method is proposed for OO class library Capturing the complete behavior of a class Considering the OO characteristics (inheritance, overloading and overriding) Techniques providing user-defined constructors neglecting argument-order storing the class info during execution Precision Conclusions high precision because it actually compares the behavior of class with expected behavior improve precision by allowing input constructor, observer and modifier Recall improve recall by allowing defined constructor to create instance & by neglect argument order Efficiency type checking & run time storage Future work It can be extended to include the userdefined types Access modifier matching can be added to before execution 6