1 Predicting Classes in Need of R Predicting Classes in Need of R efactoring – An Application of efactoring – An Application of Static Metrics Static Metrics Liming Zhao Jane Hayes Liming Zhao Jane Hayes [email protected][email protected][email protected][email protected]23 September 2006 23 September 2006 2006 International PROMISE Workshop 2006 International PROMISE Workshop
23
Embed
1 Predicting Classes in Need of Refactoring – An Application of Static Metrics Liming Zhao Jane Hayes 23 September 2006.
3 Motivation Cost of software maintenance Cost of software maintenance Refactoring Refactoring Importance of refactoring planning Importance of refactoring planning Need for improving multiple classes Need for improving multiple classes Deadlines, human resources, budgets Deadlines, human resources, budgets
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
11
Predicting Classes in Need of RefactorPredicting Classes in Need of Refactoring – An Application of Static Metricsing – An Application of Static MetricsLiming Zhao Jane HayesLiming Zhao Jane [email protected]@uky.edu [email protected]@cs.uky.edu
23 September 2006 23 September 2006 2006 International PROMISE Workshop 2006 International PROMISE Workshop
22
Predicting Classes in Need of Predicting Classes in Need of Refactoring: Refactoring:
An Application of Static MetricsAn Application of Static Metrics Motivation Motivation Related workRelated work Design of the toolDesign of the tool Study designStudy design Study resultsStudy results Conclusions and future workConclusions and future work
33
Motivation Motivation Cost of software maintenanceCost of software maintenance RefactoringRefactoring Importance of refactoring planningImportance of refactoring planning
Need for improving multiple classesNeed for improving multiple classes Deadlines, human resources, budgetsDeadlines, human resources, budgets
44
Refactoring stepsRefactoring steps Identify code segments Identify code segments Evaluate possible costs and benefits Evaluate possible costs and benefits Develop refactoring plan Develop refactoring plan Apply the refactoringsApply the refactorings
55
Why use a class-based Why use a class-based approach? approach?
Related work: Maintainability Related work: Maintainability assessmentassessment
OO metrics – Chidamber and Kemerer [1OO metrics – Chidamber and Kemerer [1994]994] MI – Welker [1995] MI – Welker [1995] PM and MP – Hayes et al. [2004] PM and MP – Hayes et al. [2004] Assessment of UML artifacts - Hassan et Assessment of UML artifacts - Hassan et al. [2005] al. [2005] RDC ratio – Hayes and Zhao [2005]RDC ratio – Hayes and Zhao [2005]
99
Related work: RefactoringRelated work: Refactoring Preconditions – Opdyke [1992] Preconditions – Opdyke [1992] Bad smells – Fowler et al. [1999] Bad smells – Fowler et al. [1999] Detecting bad smells – Mens et al. [2003] Detecting bad smells – Mens et al. [2003] Member similarity – Simon et al. [2001] Member similarity – Simon et al. [2001]
1010
Metrics examinedMetrics examined Halstead metricsHalstead metrics Cyclomatic complexity Cyclomatic complexity Weighted method per classWeighted method per class Maintainability indexMaintainability index
1111
Class-based rankClass-based rank Cost concernCost concern Priority class listPriority class list Individual rankIndividual rank Comprehensive rankComprehensive rank
1212
Code repository analysis and Code repository analysis and metrics collectionmetrics collection
Code repository analyzerCode repository analyzer Java front endJava front end
Abstract syntax tree Abstract syntax tree MetricsMetrics
classes) from software engineering classes) from software engineering class projectclass project
Pre-reading: Questionnaire about Pre-reading: Questionnaire about background, smell-list, etc.background, smell-list, etc.
1515
Study design: procedureStudy design: procedure Procedure instructed: Procedure instructed:
Fill in the questionnaire and read about the smell lFill in the questionnaire and read about the smell listist Read the code and look for “bad smells”; select Read the code and look for “bad smells”; select a smell from a provided list or fill in a problem obsa smell from a provided list or fill in a problem observed that was not in the listerved that was not in the list Find the class with the most serious problems that Find the class with the most serious problems that should be refactored first should be refactored first Record the time spent reviewing/reading each claRecord the time spent reviewing/reading each classss
1616
Study Result: Compare Study Result: Compare reviewers’ selection with tool’s reviewers’ selection with tool’s
#1#1 I1I1 AA GG AA AA GG AA#2#2 FF WW TT P P EE H H LOLO#3#3 WW LOLO AA SS GG HH#4#4 GG VV LL WW HH PP#5#5 PP SS M M LOLO FF#6#6 PP LL Legend of class name abbreviations: A - AnimationScreen, F-FileOutPut, Legend of class name abbreviations: A - AnimationScreen, F-FileOutPut,
L-LoginScreen, P- PitchAnalyzer, S- SessionReport, E- ErrorWindow, G- L-LoginScreen, P- PitchAnalyzer, S- SessionReport, E- ErrorWindow, G-Graphic, LO - LoudnessAnalyzer, R- RegistrationScreen, T - TestScreen, Graphic, LO - LoudnessAnalyzer, R- RegistrationScreen, T - TestScreen, F- FileInputHandler, H - HistoryReport, M - MenuScreen, W- Welcome, I1 F- FileInputHandler, H - HistoryReport, M - MenuScreen, W- Welcome, I1 – ImagePanel1, I2 – ImagePanel2, L – LoginScreen – ImagePanel1, I2 – ImagePanel2, L – LoginScreen
1717
Class AnimationClass Animation Noted by 67% of the reviewers and the tNoted by 67% of the reviewers and the tool (ranked 1ool (ranked 1stst by 50% of the reviewers a by 50% of the reviewers and the tool)nd the tool) Largest halstead_effort and smallest MILargest halstead_effort and smallest MI Long method per class (LMC) and ComplLong method per class (LMC) and Complex method per class (CMC) above averagex method per class (CMC) above average (Slide 43) e (Slide 43)
1818
Metrics of class animationMetrics of class animationHalstead-Halstead-LL
Study resultsStudy results Tool and half of reviewers noted Tool and half of reviewers noted
class Animation as worstclass Animation as worst Reviewers spent a significant amount Reviewers spent a significant amount
of time (1-3 hours)of time (1-3 hours) More “easy” problems found (90%)More “easy” problems found (90%) Reviewers looked for different smells Reviewers looked for different smells
(28% not in list) (28% not in list)
2020
ConclusionsConclusions Complexity and size are among the Complexity and size are among the
major factors making comprehension major factors making comprehension hardhard
Reviewers are looking for different Reviewers are looking for different problems problems
Code reviewing is time-consuming Code reviewing is time-consuming Automation can help consistency, Automation can help consistency,
efficiency, and effectivenessefficiency, and effectiveness
2121
Future workFuture work Predict the possible cost of the Predict the possible cost of the
refactoring and its impact on code refactoring and its impact on code maintainabilitymaintainability
Use metrics from evolution historyUse metrics from evolution history Use metrics reflecting inter-class Use metrics reflecting inter-class
relationshipsrelationships
2222
AcknowledgementsAcknowledgements Thanks to Edison Design Group for Thanks to Edison Design Group for
providing JFEproviding JFE Thanks to the graduate student Thanks to the graduate student
volunteers for participating in the volunteers for participating in the study study