Share
Embed
Transcript
30 slides
-
Benevol 2014, Nov 11-12! CWI, Amsterdam Luis Mayorga Inferring Bad
Smell Removal Recipes from Repository Mining: an initial exploration Universidad Politécnica de Madrid! (Erasmus student at Ansymo) Javier Pérez Ansymo, University of Antwerp, Belgium -
Refactoring Recipes How to automate them? Bad Smells Disharmonies to
/ away! patterns -
The Problem PrintServer formatSummary(): String setLastDocument(d: Document): void getLastDocument: Document
printDocument(): void lastDocument: Document formatDocument: String formatSummary(): String content: String name: String author: String creationDate: Date Document ✤ formatSummary() of PrintServer suffers from Feature Envy ✤ Trivial strategy: apply Move Method from PrintServer to Document ✤ Refactoring precondition violation: same signature conflict ✤ Additional refactorings are needed to enable the precondition ✤ Different refactoring sequences for each particular case -
Refactoring Strategy • incrementally composable • semiformal • "gaps" are
computable Recipes to Refactoring Strategies “Refactoring Planning for Design Smell Correction in Object-Oriented Software” Javier Pérez; PhD Thesis, July 2011, University of Valladolid -
Refactoring Planning Compute ! "Remove DataClass" Current Source Code Refactoring
Strategy HTN automated planning ? -
Refactoring Planning 01. increase visibility! 02. move method! 03. increase
visibility! 04. move method! 05. increase visibility! 06. increase visibility! 07. increase visibility! 08. move method! 09. encapsulate field! 10. remove-method! 11. remove-method! 12. remove-method Compute ! "Remove DataClass" Current Source Code Refactoring Strategy -
V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring
Strategy S1 ... Sn R1 ... Rn General Mining Approach -
V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring
Strategy S1 ... Sn R1 ... Rn Available Mature Tools General Mining Approach -
V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring
Strategy S1 ... Sn R1 ... Rn Available Mature Tools General Mining Approach -
V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring
Strategy S1 ... Sn R1 ... Rn Available Mature Tools Ref-Finder General Mining Approach -
Experiments Summary • 4 open-source projects analysed: • Hibernate, JHotdraw,
JEdit, PMD ! ! ! • Refactorings found for 6 smells! • Data Class, Schizophrenic Class, Blob Operation, Feature Envy, Intensive Coupling • Resources available at: • https://github.com/rapsioux/nose -
Smell detection - sampling each 5 revisions Process Overview s
Evolution database XML Quality reports transformation and load Bad smell disappearances repository inFusion analysis Evolu datab XML Quality reports transformation and load Analyse revisions before and after the smell Manually inspect the refactorings detected Evolution database transformation and load refFinder analysis Bad smell disappearances Ref-Finder -
Data overview: Hibernate 0.0 2.5 5.0 7.5 10.0 1000 1200
1400 Revision Bad smell count 1600 1800 2000 2200 1000 1200 1400 Revision Bad smell count total smells! ! ! smells removed! ! ! -
Data overview: JEdit 750 775 800 825 850 7400 7450
7500 Revision Bad smell count 0.00 0.25 0.50 0.75 1.00 7400 7450 7500 Revision Bad smell count 7456 "Enhancements suggested by IntelliJIDEA" total! smells! ! ! smells! removed! ! ! -
Data overview: JHotdraw 176! Change in package structure 0 200
400 600 100 200 300 Revision Bad smell count 0 10 20 30 40 100 200 300 Revision Bad smell count total! smells! ! ! smells! removed! ! ! -
Data overview: PMD 4882! Matched maven package structure 4935! Turn
pmd-build into mvn plugin 150 160 170 180 190 200 4750 4800 4850 4900 4950 5000 Revision Bad smell count 0 10 20 30 4750 4800 4850 4900 4950 5000 Revision Bad smell count total! smells! ! ! smells! removed! ! ! -
Refactorings Found • Smells track gets lost due to •
renamings • package reorganisation (big changes) ! • Few refactorings found • detection launched only on a few cases • non-useful renamings detected -
Refactorings Found: Blob Operation 01. inline temp! 02. extract method!
03. replace method with method object Blob Operation 01. extract method! -
Refactorings Found: Feature Envy 01. inline temp! 02. extract method!
03. replace method with method object 01. inline method 01. extract method Feature Envy -
Can we mine! refactoring strategies? Can we automate! refactoring strategies?
Yes! So far so good … -
Conclusions and limitations so far • It seems developers don't
care about removing bad smells • Recipes found refine those from common catalogues (Fowler, …) • Smarter interpretation of the detections needed • understands semantics of changes • Bad Smell Detection • time consuming • 5 revisions sample frequency • Smells tracking (renamings) • Refactoring Detection • False positives & false negatives • More fine-grained revisions (Git, IDE recording)