Refactoring Software Projects Using Object Oriented Concepts Ankit Desai 1, Jaimin Chavda 2, Amit Ganatra 3, Amit Thakkar 4, Yogesh Kosta 5 Charotar Institute.

Slides:



Advertisements
Similar presentations
When is Orientated Programming NOT? Mike Fitzpatrick.
Advertisements

Class Scope class Student { private: string id; string firstName, lastName; float gpa; public: void Read() { cin >> id >> firstName >> lastName >> gpa;
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
Object Oriented Programming in Java. Object Oriented Programming Concepts in Java Object oriented Programming is a paradigm or organizing principle for.
Software Engineering Class design. Class design – ADT Abstract Data Types:  Why use ADT? Hidden implementation details Changes do not affect whole program.
1 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
Introduction to Object Oriented Programming Java.
Department of computer science N. Harika. Inheritance Inheritance is a fundamental Object Oriented concept A class can be defined as a "subclass" of another.
Introduction To System Analysis and Design
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
1 Chapter 7 l Inheritance Basics l Programming with Inheritance l Dynamic Binding and Polymorphism Inheritance.
1 Inheritance and Polymorphism Inheritance (Continued) Polymorphism Polymorphism by inheritance Polymorphism by interfaces Reading for this lecture: L&L.
Fall 2007CS 2251 Software Engineering Intro. Fall 2007CS 2252 Topics Software challenge Life-cycle models Design Issues Documentation Abstraction.
Object-oriented Programming Concepts
Object Oriented Paradigm Programming Paradigms En Mohd Norafizal A.Aziz.
C++ fundamentals.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
Chapter 10: Inheritance 1. Inheritance  Inheritance allows a software developer to derive a new class from an existing one  The existing class is called.
Like our natural language. Designed to facilitate the expression and communication ideas between people and computer Like our natural language. Designed.
OOP- OBJECT OBJECT PROGRAMMING By KRATI SHARMA 02 XI-B ✏✏✏✏ ☺☻☺☻☺☻☺ ✏✏✏✏
Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Object Oriented Programming (OOPs) Class Object Data Hiding Abstraction Encapsulation Polymorphism Inheritance Difference between Procedural and OOPs programming.
© S. Demeyer, S. Ducasse, O. Nierstrasz Intro.1 1. Introduction Goals Why Reengineering ?  Lehman's Laws  Object-Oriented Legacy Typical Problems  common.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Introduction To System Analysis and Design
Partitioning and Layering Fundamentals. The Basic Problem Change is a fact of life RequirementsTechnologies Bug Fixes Software Must Adapt.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Software Engineering 1 Object-oriented Analysis and Design Chap 21 Test-Driven Development and Refactoring.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Encapsulation COMP 401, Fall 2014 Lecture 06 9/4/2014.
Frameworks & Patterns Use of Organized Classes. Frameworks vs Toolkits Framework Framework  Start with classes and interfaces that define a rudimentary.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Simple Classes. ADTs A specification for a real world data item –defines types and valid ranges –defines valid operations on the data. Specification is.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Designing Classes. Software changes Software is not like a novel that is written once and then remains unchanged. Software is extended, corrected, maintained,
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
: Maha Sabri Altememe Lecturer : Maha Sabri Altememe Lecture :1 1.
Salman Marvasti Sharif University of Technology Winter 2015.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA, Dc. Sc. & Engg.
Foundations: Language mechanisms and primitive OO concepts Lecture 1: Classification and Inheritance Michigan State University Spring 2008 E. Kraemer Notes.
Session 6 Comments on Lab 3 & Implications of Inheritance.
Topics Inheritance introduction
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)
OO in Context Lecture 13: Dolores Zage. Confused about OO Not alone, there is much confusion about OO many programs are claimed to be OO but are not really.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
1 CS 132 Spring 2008 Chapter 1 Software Engineering Principles and C++ Classes.
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Inheritance Chapter 7 Inheritance Basics Programming with Inheritance
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
CHAPTER 5 GENERAL OOP CONCEPTS.
Chapter 5: Object Oriented Analysis and Design
COMPUTER 2430 Object Oriented Programming and Data Structures I
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Object Oriented Analysis and Design
Inheritance Basics Programming with Inheritance
Computer Programming with JAVA
CPS120: Introduction to Computer Science
By Rajanikanth B OOP Concepts By Rajanikanth B
C++ Programming CLASS This pointer Static Class Friend Class
CPS120: Introduction to Computer Science
Presentation transcript:

Refactoring Software Projects Using Object Oriented Concepts Ankit Desai 1, Jaimin Chavda 2, Amit Ganatra 3, Amit Thakkar 4, Yogesh Kosta 5 Charotar Institute of Technology, Charotar University of Science and Technology – Changa

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Theme  Software Re-Engineering and Refactoring  Refactoring Opportunities  Conclusion  Summary

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Software Re-Engineering and Refactoring  Software re-engineering is concerned with re- implementing older systems to improve them or make them more maintainable, while Refactoring is re- engineering with-in an Object-Oriented context.  Transformation from one representation form to another.  Preserving the systems’ external behavior.

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Refactoring Opportunities  class misuse  violation of the principle of encapsulation  lack of use of inheritance concept  misuse of inheritance  misplaced polymorphism

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Class misuse  The most fundamental mistake done in developing a program in OOP context is not designing a class properly.  One bad class design has a cumulative effect on all other classes in the entire software.

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Example 1: class Employee{ private: int employee_id; String designation, dept_name; float da, basic, gross; public: print(); ……. } class EmpAddress{ private: int employee_id; String apartment_no, flat_name, street_name; public: printk(); ……. } class EmpName { private: int employee_id; String first_name, middle_name, last_name; public: printl(); ……. }  E.g. Three times employee_id separately.  Fetch and delete operation is cumbersome.  Inheritance is not a solution every- time.  Poor design

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Facts Complexity Measures Before Applying Refactoring Refactoring Cost Refactoring Opportunities SpaceTimeDesign Class MisuseVery HighHigh Low

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Violation of the principle of Encapsulation (data hide)  For example, it is possible for a Java class to obtain the names of all its members and display them.  As shown in Example1, class-misuse leads us to use reflection.Example1  Reflection in JAVA violates the principal of Encapsulation.

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Facts Complexity Measures Before Applying Refactoring Refactoring Cost Refactoring Opportunities SpaceTimeDesign Class MisuseVery HighHigh Low Violation of the principal of encapsulation Not Applicable Very High

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Lack of use of Inheritance Concept Example 2: class X{ private: int i, j; public: void set(); void show(); } Example 3: class Y extends X{ private: int k; public: void showk(); } Example 4: class Y{ private: int i,j,k; public: void set(); void show(); void showk(); }  Duplicating effort, if not inherited.  Programmers tend to define their classes right form the scratch.

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Facts Complexity Measures Before Applying Refactoring Refactoring Cost Refactoring Opportunities SpaceTimeDesign Class MisuseVery HighHigh Low Violation of the principal of encapsulation Not Applicable Very High Lack of use of Inheritance Concept Very highMediumVery HighHigh

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Misuse of Inheritance Example 5: class A{ private: int i, j, k; public: void show(); void setall(); } Example 6: class B{ private: int j, k, l; public: void show(); void setall(); void showk(); }  Dangling variables are dangerous.  If class B is inherited from class A then there will be an extra variable ‘i’ which is not necessary for class B.  Inheritance is more to achieve Polymorphism rather to code reuse.

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Facts Complexity Measures Before Applying Refactoring Refactoring Cost Refactoring Opportunities SpaceTimeDesign Class MisuseVery HighHigh Low Violation of the principal of encapsulation Not Applicable Very High Lack of use of Inheritance Concept Very highMediumVery HighHigh Misuse of Inheritance Not Applicable High Medium

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Misplaced Polymorphism  Functions performing the same action on different data types should be given the same name.  Example. push() & pop() functions working for different data data-types. Case1. functions to work for int char and float  Same name, different behavior Case2. initially for int. then add for char and float  Different names, different behavior  This provides good opportunity for refactoring.

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Conclusion Complexity Measures Before Applying Refactoring Refactoring Cost Refactoring Opportunities SpaceTimeDesign Class MisuseVery HighHigh Low Violation of the principal of encapsulation Not Applicable Very High Lack of use of Inheritance Concept Very highMediumVery HighHigh Misuse of Inheritance Not Applicable High Medium Misplaced Polymorphism High Very Low HighVery Low

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Summary  Software Re-Engineering vs Refactoring  Refactoring Opportunities class misuse  Examle 1 violation of the principle of encapsulation lack of use of inheritance concept misuse of inheritance misplaced polymorphism  java.lang.UnsupportedClassVersionError  Conclusion Table

Refactoring Software Projects Using Object Oriented ConceptsU. & P.U.PATEL DEPT. OF COMPUTER ENGG. Thank You…  Questions…???