Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Refactoring.

Slides:



Advertisements
Similar presentations
Metrics for OO Design Distinct & measurable characteristics of OO design:- Size:-it is defined as – population,volume,length & functionality Population.
Advertisements

Software Metrics for Object Oriented Design
Presentation of the Quantitative Software Engineering (QuaSE) Lab, University of Alberta Giancarlo Succi Department of Electrical and Computer Engineering.
1 Predicting Bugs From History Software Evolution Chapter 4: Predicting Bugs from History T. Zimmermann, N. Nagappan, A Zeller.
Prediction of fault-proneness at early phase in object-oriented development Toshihiro Kamiya †, Shinji Kusumoto † and Katsuro Inoue †‡ † Osaka University.
Figures – Chapter 24.
Metrics for Object Oriented Design Shyam R. Chidamber Chris F. Kemerer Presented by Ambikadevi Damodaran.
March 25, R. McFadyen1 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity Comment percentage Length of identifiers Depth of conditional.
Nov R. McFadyen1 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity* Comment percentage Length of identifiers Depth of conditional.
Object Oriented Design
Page 1 Building Reliable Component-based Systems Chapter 7 - Role-Based Component Engineering Chapter 7 Role-Based Component Engineering.
Analysis of CK Metrics “Empirical Analysis of Object-Oriented Design Metrics for Predicting High and Low Severity Faults” Yuming Zhou and Hareton Leung,
Design Metrics Software Engineering Fall 2003 Aditya P. Mathur Last update: October 28, 2003.
Software engineering for real-time systems
Software Quality Metrics
© S. Demeyer, S. Ducasse, O. Nierstrasz Duplication.1 7. Problem Detection Metrics  Software quality  Analyzing trends Duplicated Code  Detection techniques.
Software Metrics II Speaker: Jerry Gao Ph.D. San Jose State University URL: Sept., 2001.
Object-Oriented Metrics
March R. McFadyen1 Software Metrics Software metrics help evaluate development and testing efforts needed, understandability, maintainability.
Predicting Class Testability using Object-Oriented Metrics M. Bruntink and A. van Deursen Presented by Tom Chappell.
Lecture 17 Software Metrics
A Survey of Software Refactoring Tom Mens, Tom Tourwé
Chidamber & Kemerer Suite of Metrics
Systems Analysis – Analyzing Requirements.  Analyzing requirement stage identifies user information needs and new systems requirements  IS dev team.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Finding Similar.
Japan Advanced Institute of Science and Technology
Chapter 6 : Software Metrics
Paradigm Independent Software Complexity Metrics Dr. Zoltán Porkoláb Department of Programming Languages and Compilers Eötvös Loránd University, Faculty.
Software Measurement & Metrics
Quality Assessment for CBSD: Techniques and A Generic Environment Presented by: Cai Xia Supervisor: Prof. Michael Lyu Markers: Prof. Ada Fu Prof. K.F.
The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of.
1 OO Metrics-Sept2001 Principal Components of Orthogonal Object-Oriented Metrics Victor Laing SRS Information Services Software Assurance Technology Center.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Applying Clone.
The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of.
Concepts of Software Quality Yonglei Tao 1. Software Quality Attributes  Reliability  correctness, completeness, consistency, robustness  Testability.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University How to extract.
Software Engineering Research Group, Graduate School of Engineering Science, Osaka University 1 Evaluation of a Business Application Framework Using Complexity.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
1 Metrics and lessons learned for OO projects Kan Ch 12 Steve Chenoweth, RHIT Above – New chapter, same Halstead. He also predicted various other project.
An Automatic Software Quality Measurement System.
CSc 461/561 Information Systems Engineering Lecture 5 – Software Metrics.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Classification.
West Virginia University Sherif Yacoub, Hany H. Ammar, and Ali Mili A UML Model for Analyzing Software Quality Sherif Yacoub, Hany H. Ammar, and Ali Mili.
Object-Oriented (OO) estimation Martin Vigo Gabriel H. Lozano M.
Ontology Support for Abstraction Layer Modularization Hyun Cho, Jeff Gray Department of Computer Science University of Alabama
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Object Oriented Metrics
Software Engineering Lecture 19: Object-Oriented Testing & Technical Metrics.
1 OO Technical Metrics CIS 375 Bruce R. Maxim UM-Dearborn.
CS223: Software Engineering Lecture 21: Unit Testing Metric.
Department of Computer Science, Graduate School of Information Science & Technology, Osaka University A Metric-based Approach for Reconstructing Methods.
Design Metrics CS 406 Software Engineering I Fall 2001 Aditya P. Mathur Last update: October 23, 2001.
Estimating Code Size After a Complete Code-Clone Merge Buford Edwards III, Yuhao Wu, Makoto Matsushita, Katsuro Inoue 1 Graduate School of Information.
Object Oriented Metrics
Software Metrics 1.
Course Notes Set 12: Object-Oriented Metrics
Design Characteristics and Metrics
Towards a Multi-paradigm Complexity Measure
Object-Oriented Metrics
Design Metrics Software Engineering Fall 2003
A Pluggable Tool for Measuring Software Metrics from Source Code
Design Metrics Software Engineering Fall 2003
Software Metrics Validation using Version control
Mei-Huei Tang October 25, 2000 Computer Science Department SUNY Albany
Predicting Fault-Prone Modules Based on Metrics Transitions
Software Metrics SAD ::: Fall 2015 Sabbir Muhammad Saleh.
On Refactoring Support Based on Code Clone Dependency Relation
Software Metrics using EiffelStudio
Chapter 8: Design: Characteristics and Metrics
Presentation transcript:

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Refactoring Effect Estimation Based on Complexity Metrics Yoshiki Higo, Yoshihiro Matsumoto, Shinji Kusumoto, Katuro Inoue

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 2 What’s Refactoring? A set of operations to improve internal attributes of a software system without changing the external behavior of it One of trenchant countermeasures to handle large- scale and complex software systems

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Refactoring operating procedure 1. Identify where the software should be refactored 2. Determine which refactoring should be applied to the identified place 3. Guarantee that the applied refactoring preserves the behavior 4. Apply the refactoring 5. Assess the effect of the refactoring on quality characteristics of the software 6. Maintain the consistency between the refactored program code and other software artifacts 3

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Refactoring requires costs A refactoring requires a certain cost to be completed  Its impact should justify the cost 4 It is difficult to precisely estimate the effect of refactorings on the early stage of the refactoring Inappropriate refactorings may be performed instead of appropriate ones Inappropriate refactorings become software systems less maintainable or require much cost to be completed

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposal Technique -Overview- We propose a method estimating refactoring effect  INPUT: refactorings that developers are going to perform  OUTPUT: effect estimation of each of the refactorings The method estimates refactoring effect from the following viewpoints (by using CK metrics suite)  How coupling between classes will change,  How cohesion of each class will change,  How inheritance relationships between classes will change 5

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University CK Metrics Suite Measures complexity of object-oriented software [1] 6 Better indicator to estimate occurrences of faults than other metrics [2] InheritanceDIT (Depth of Inheritance Tree) NOC (Number Of Children) CouplingRFC (Response For a Class) CBO (Coupling Between Object-class) CohesionWMC (Weighted Method per Class) LCOM (Lack Of Cohesion Method) [1] S. Chidamber and C. Kemerer. A metric suite for object-oriented design. IEEE Transactions on Software Engineering, 25(5):476–493, Jun [2] V. R. Basili, L. C. Briand, and W. L. Melo. A validation of object-oriented design metrics as quality indicators. IEEE Transactions on Software Engineering, 22(10):751–761, Oct 1996.

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposal Technique 7 refactoring pattern original structure A B C D revised structure A B’ C’ D program D C B A ・・・ D C B A LCOMFRCCBONOCDITWMC metrics of the original structure ・・・ D C’ ・・・ B’ ・・・ A LCOMFRCCBONOCDITWMC metrics of the revised structure input comparison result output STEP1STEP2 STEP3 STEP4 STEP5 STEP6

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposal Technique -STEP1- The whole of the target program is parsed to construct a structure representing it  The structure includes all information required to measure CK metrics 8 output refactoring pattern original structure A B C D revised structure A B’ C’ D program D C B A ・・・ D C B A LCOMFRCCBONOCDITWMC metrics of the original structure ・・・ D C’ ・・・ B’ ・・・ A LCOMFRCCBONOCDITWMC metrics of the revised structure input comparison result output STEP1STEP2 STEP3 STEP4 STEP5 STEP6

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposal Technique -STEP2- CK metrics are measured from the structure  These metrics represent the complexity of the original program 9 refactoring pattern original structure A B C D revised structure A B’ C’ D program D C B A ・・・ D C B A LCOMFRCCBONOCDITWMC metrics of the original structure ・・・ D C’ ・・・ B’ ・・・ A LCOMFRCCBONOCDITWMC metrics of the revised structure input comparison result output STEP1STEP2 STEP3 STEP4 STEP5 STEP6

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposal Technique -STEP3- The refactorings that developers are going to perform are input  Where of the target program is refactored  How the part is refactored 10 refactoring pattern original structure A B C D revised structure A B’ C’ D program D C B A ・・・ D C B A LCOMFRCCBONOCDITWMC metrics of the original structure ・・・ D C’ ・・・ B’ ・・・ A LCOMFRCCBONOCDITWMC metrics of the revised structure input comparison result output STEP1STEP2 STEP3 STEP4 STEP5 STEP6

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposal Technique -STEP4- The structure is revised based on the refactorings input in STEP3 11 refactoring pattern original structure A B C D revised structure A B’ C’ D program D C B A ・・・ D C B A LCOMFRCCBONOCDITWMC metrics of the original structure ・・・ D C’ ・・・ B’ ・・・ A LCOMFRCCBONOCDITWMC metrics of the revised structure input comparison result output STEP1STEP2 STEP3 STEP4 STEP5 STEP6

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University STEP4 It is impossible to fully-automatically revise the structure  Some operations require developer’s intention STEP4 consists of automatic and interactive change Example: method a1 in class A is moved to class B A a1( ) a2( ) call a1( ) D d1( ) B b1( ) C c1( ) call a1( ) D’ d1( ) C’ c1( ) B’ b1( ) a1( ) A’ a2( ) Original programRevised program

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University STEP4 -Automatic change- Automatic change is completely automatic processing, it doesn’t require developer’s interventions In the example,  Delete method a1 from class A, and add it to class B,  In class B, a1 invocations are changed as internal method invocations A a1( ) a2( ) D d1( ) C c1( ) B b1( ) *** instructionoffset Method b1() ・ ・ ・ ・ ・ ・ (ClassA)instanceA.a1() (ClassB)a1() modify automatically move automatically a1( )

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University STEP4 -Interactive change- Some operations require developer’s interventions, they cannot be completed automatically In the example,  A developer needs to determine which instance invokes method a1 in class C and D After receiving her intervention, the method revises the structure based on it D d1( ) C c1( ) B b1( ) a1( ) (ClassA)instanceA.a1() *** instructionoffset Method d1() ・ ・ ・ ・ ・ ・ (ClassA)instanceA.a1() *** instructionoffset Method c1() ・ ・ ・ ・ ・ ・ (ClassB)???.a1() Can’t modify automatically A a2( )

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposal Technique -STEP5- CK metrics are measured from the revised structure  These metrics represent the complexity of the revised program 15 refactoring pattern original structure A B C D revised structure A B’ C’ D program D C B A ・・・ D C B A LCOMFRCCBONOCDITWMC metrics of the original structure ・・・ D C’ ・・・ B’ ・・・ A LCOMFRCCBONOCDITWMC metrics of the revised structure input comparison result output STEP1STEP2 STEP3 STEP4 STEP5 STEP6

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Proposal Technique -STEP6- The technique outputs how the complexity of the target software will change by performing the refactoring 16 refactoring pattern original structure A B C D revised structure A B’ C’ D program D C B A ・・・ D C B A LCOMFRCCBONOCDITWMC metrics of the original structure ・・・ D C’ ・・・ B’ ・・・ A LCOMFRCCBONOCDITWMC metrics of the revised structure input comparison result output STEP1STEP2 STEP3 STEP4 STEP5 STEP6

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Change Rate The output is Change Rate, which is a quantitative result of the effect estimation The below formula represents the change rate of metric WMC in the example  A, B, C, and D are classes in the original structure  A’, B’, C’, and D’ are ones in the revised structure  WMC(x) is the value of metric WMC for class x Only the classes affected by the refactoring are used for calculating change rate 17

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Implementation (a prototype) Target language: Java Structure representing the program: Bytecode  There are useful and practical tools/libraries to handle bytecode Target refactorings:  Move Field, Pull Up Field, Pull Down Field  Move Method, Pull Up Method, Pull Down Method  Extract Class, Extract SuperClass, Extract SubClass

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Outline- We conducted a small case study to evaluate the usefulness of the proposed technique Target is a program developed by a single master student  The number of classes is 37, the LOC is 4,815  It has been maintained for about 1 year We manually identified which modules had undesirable conditions with the master student We thought out 4 refactoring candidates to improve the modules

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Identified Problem- Class ComponentList (CL) was designed not related to GUI originally CL Extract Panel ep; setExtractPanel() setStartClass() GVP BPFLGV CP GUI classes But, after 1-year maintenance, CL has a function related to GUI  The function consists of 1 field and 2 methods

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Refactoring Candidates- The variable and the methods should be moved to another class related to GUI CL Extract Panel ep; setExtractPanel() setStartClass() GVP BPFLGV CP GUI classes CASE1: FeatureLocationGraphViewer (FLGV) CASE2: BirdPanel (BP) CASE3: ComponentPanel (CP) CASE4: GraphViewPanel (GVP)

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Tool’s result- All candidates will not change the change rates of metrics WMC, DIT, NOC, and LCOM All candidates will have no or a little bit of change on metric RFC CASE1 will be able to greatly reduce the change rate of metric CBO while all of other candidates will increase it. CASE1CASE2CASE3CASE4 WMC0.0 DIT0.0 NOC0.0 CBO RFC LCOM0.00

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Tool’s result- All candidates will not change the change rates of metrics WMC, DIT, NOC, and LCOM All candidates will have no or a little bit of change on metric RFC CASE1 will be able to greatly reduce the change rate of metric CBO while all of other candidates will increase it. CASE1CASE2CASE3CASE4 WMC0.0 DIT0.0 NOC0.0 CBO RFC LCOM0.00

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Tool’s result- All candidates will not change the change rates of metrics WMC, DIT, NOC, and LCOM All candidates will have no or a little bit of change on metric RFC CASE1 will be able to greatly reduce the change rate of metric CBO while all of other candidates will increase it. CASE1CASE2CASE3CASE4 WMC0.0 DIT0.0 NOC0.0 CBO RFC LCOM0.00

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Tool’s result- All candidates will not change the change rates of metrics WMC, DIT, NOC, and LCOM All candidates will have no or a little bit of change on metric RFC CASE1 will be able to greatly reduce the change rate of metric CBO while all of other candidates will increase it CASE1CASE2CASE3CASE4 WMC0.0 DIT0.0 NOC0.0 CBO RFC LCOM0.00

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Master Student’s Decision- Before tool’s application  The master student selected CASE3  He thought that class CL had a similar function to the class of CASE3  His decision was based on his instinct rather than objective basis like bug information, software metrics, or design patterns After tool’s application  He recognized that the tool’s estimation was better than his own determination, and adopted the CASE1 refactoring

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University A case study -Measurement Precision- After the estimation, we actually performed each of the 4 refactorings on the source code respectively CK metrics were measured from the refactored source code, and change rates were calculated All of the metrics and change rates were the same as ones measured from the revised bytecode

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Validity of the method No research has revealed obvious foundation that good refactoring lead to lower CK measures When a maintainer perform a refactoring, there is a obvious goal of it The proposal technique enables the maintainer to know whether the goal can be accomplished or not Side-effects of the refactoring can be represented by the change rate  The maintainer can avoid regretting the refactoring after actually performing it

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Limitations -the case study- The examinee is a single master student  We need to conduct case studies involving more examinees, which consist of different level programmers The target program size is not practical Only the change of complexity metrics values was considered as the effects of refactorings

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Limitation -the case study- The examinee is a single master student The target program size is not practical  We need to conduct case studies on more practical size software systems  But, this case study revealed that it is difficult to perform effective refactorings on even a small-size program Only the change of complexity metrics values was considered as the effects of refactorings

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Limitation -proposal technique- The examinee is a single master student The target program size is not practical Only the change of complexity metrics was considered as the effects of refactorings  Real refactorings require source code modification cost and regression test cost  In order to estimate refactoring effectiveness more precisely, we have to considerer those costs

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Conclusion and Future Works In this study, we  proposed a new technique to estimate refactoring effect  Implemented a software tool based on the proposal  Applied it to a small software system We are going to  re-implement the tool for revising not bytecode but source code, which can achieve automated source code modification  handle other refactoring patterns

Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University