Identification of Refused Bequest Code Smells E. Ligu, A. Chatzigeorgiou, T. Chaikalis, N. Ygeionomakis Department of Applied Informatics University of.

Slides:



Advertisements
Similar presentations
More on Classes Inheritance and Polymorphism
Advertisements

Object-Oriented Programming Basics Prof. Ankur Teredesai, Computer Science Department, RIT.
OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Ranking Refactoring Suggestions based on Historical Volatility Nikolaos Tsantalis Alexander Chatzigeorgiou University of Macedonia Thessaloniki, Greece.
OOP: Inheritance By: Lamiaa Said.
Chapter 7 Testing Class Hierarchies. SWE 415 Chapter 7 2 Reading Assignment  John McGregor and David A. Sykes, A Practical Guide to Testing Object-Oriented.
SEAgle: Effortless Software Evolution Analysis T. Chaikalis, E. Ligu, G. Melas and A. Chatzigeorgiou Department of Applied Informatics University of Macedonia,
ITEC200 – Week03 Inheritance and Class Hierarchies.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:
1 Software Testing and Quality Assurance Lecture 10 - The Testing Perspective (Chapter 2, A Practical Guide to Testing Object-Oriented Software)
Software engineering for real-time systems
Inheritance. In this chapter, we will cover: The concept of inheritance Extending classes Overriding superclass methods Working with superclasses that.
1 Software Testing and Quality Assurance Lecture 28 – Testing Class Hierarchies.
1 Chapter 6 Inheritance, Interfaces, and Abstract Classes.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
Investigating the Evolution of Bad Smells in Object-Oriented Code Alexander Chatzigeorgiou Anastasios Manakos University of Macedonia Thessaloniki, Greece.
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
Polymorphism. Lecture Objectives To understand the concept of polymorphism To understand the concept of static or early binding To understand the concept.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Taken from slides of Starting Out with C++ Early Objects Seventh Edition.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
© S Ramakrishnan, Monash University oops1.ppt 1 Object-Oriented Programming Systems SFT3021 Semester Lecturer: Sita Ramakrishnan
These materials where developed by Martin Schray. Please feel free to use and modify them for non-commercial purposes. If you find them useful or would.
11/09/02(c) 2002 Bo Sanden, Colorado Tech.1 OO Testing.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
SE-1020 Dr. Mark L. Hornick 1 Composition, Aggregation, and Inheritance - Introduction.
Software Engineering CS3003 Lecture 4 Code bad smells and refactoring.
Refactoring 2. Admin Blackboard Quiz Acknowledgements Material in this presentation was drawn from Martin Fowler, Refactoring: Improving the Design of.
A Formal Model for Object-Oriented Software Reuse Kim Mens Programming Technology Lab Vrije Universiteit Brussel FNRS MeetingMay 6th, 1997.
Object Oriented Programming
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
1 Software Maintenance and Evolution CSSE 575: Session 3, Part 3 Dealing with Generalization Steve Chenoweth Office Phone: (812) Cell: (937)
 Pearson Education, Inc. All rights reserved Object-Oriented Programming: Polymorphism.
Inspired by the Oulipu. The 3 Tenets of OO Encapsulation Polymorphism Inheritance.
Diagnosing Design Problems in Object Oriented Systems Adrian Trifu, Radu Marinescu Proceedings of the 12th IEEE Working Conference on Reverse Engineering.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 3- Introduction to Object Oriented Programming concepts Topic 3.4 Constructors, Overloading,
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Polymorphism. Superclass and Subclass Inheritance defines a relationship between objects that share characteristics. It is a mechanism.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Software Construction and Evolution - CSSE 375 Dealing with Generalization Steve and Shawn Left – In the 1990 movie “The Freshman,” Matthew Broderick,
Module 9. Dealing with Generalization Course: Refactoring.
Polymorphism Lecture - 9.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Chapter 12: Support for Object- Oriented Programming Lecture # 18.
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.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Polymorphism in Methods
Object-Oriented Programming Basics
Object-Oriented Programming
Chapter 3 Inheritance © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Types of Programming Languages
Object-Oriented Programming: Polymorphism
Object Oriented Programming
Chapter 10 Thinking in Objects
CS240: Advanced Programming Concepts
Week 6 Object-Oriented Programming (2): Polymorphism
Code Smells 1.
Advanced Java Programming
Chapter 19 Testing Object-Oriented Applications
Chapter 11 Inheritance and Polymorphism
Java Programming, Second Edition
Chapter 19 Testing Object-Oriented Applications
Inheritance.
Object Oriented Analysis and Design
Method Overriding and method Overloading
Refactoring.
Presentation transcript:

Identification of Refused Bequest Code Smells E. Ligu, A. Chatzigeorgiou, T. Chaikalis, N. Ygeionomakis Department of Applied Informatics University of Macedonia, Greece ICSM’2013, Early Research Achievements Track, September 24, 2013

Context In the world of OO systems, inheritance is not a panacea Mammal + breatheAir() + regulateBodyTemp() + giveBirthToLiveYoung() + produceMilkIfFemale() + swim() + breatheAir() + regulateBodyTemp() + giveBirthToLiveYoung() + produceMilkIfFemale() + swim() + breatheAir() + regulateBodyTemp() + giveBirthToLiveYoung() + produceMilkIfFemale() + swim()

Problem Goal: Identification of Refused Bequest Code Smells Refused Bequest: “a subclass does not want to support the interface inherited from its parent class” [Fowler] non-trivial problem to resolve Appropriate Refactoring: Replace Inheritance with Delegation Famous quote: “Favor Composition over Inheritance” [GoF]

Key Concept public interface which is inherited is the subclass using the inherited interface? OK indication of Refused Bequest

Smell Thermometer Refused Bequest is highly improbable: -inherited methods have been re- implemented to provide functionality that is specific to the subclass -> goal is to enable polymorphism. -the presence of errors -> inherited functionality is actually employed. Signs of Refused Bequest : -no superclass method is overridden -no inherited method is invoked on subclass instances -no super class method invocations No argument in favor of inheritance

Example SweetHome 3D v.4.0 LOC: 76K, 460 classes, 69 hierarchies, 42 test cases

Tool Implementation on top of the JDeodorant tool

Threat to Validity Assumption: unit tests exercise thoroughly system functionality Threat to construct validity: introduced errors might not lead to test failures because tests have not been designed to cause the invocation of the corresponding methods and not because the methods are not actually utilized. Mitigation: perform identification on projects with extensive test coverage

Question 1 (academic): Would you trust an automated tool to identify and resolve design defects on its own? Question 2 (provocative): Do you think that industrial engineers actually regard the resolution of smells as a (serious) way to improve the code? ICSM’2013, Early Research Achievements Track, September 24, 2013