Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Refactoring Software Projects Using Object Oriented Concepts Ankit Desai 1, Jaimin Chavda 2, Amit Ganatra 3, Amit Thakkar 4, Yogesh Kosta 5 Charotar Institute."— Presentation transcript:

1 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 1 ankitdesai.it@ecchanga.ac.in 2 jaiminchavda.it@ecchanga.ac.in 3 amitganatra.ce@ecchanga.ac.in 4 amitthakkar.it@ecchanga.ac.in 5 ypkosta.rec@ecchanga.ac.in

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

3 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.

4 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

5 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.

6 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

7 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

8 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.

9 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

10 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.

11 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

12 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.

13 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

14 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.

15 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

16 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

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


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

Similar presentations


Ads by Google