Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Recommending Move Method Refactorings Using Dep...

Recommending Move Method Refactorings Using Dependency Sets (WCRE 2013)

Methods implemented in incorrect classes are common bad smells in object-oriented systems, especially in the case of systems maintained and evolved for years. To tackle this design flaw, we propose a novel approach that recommends Move Method refactorings based on the set of static dependencies established by a method. More specifically, our approach compares the similarity of the dependencies established by a source method with the dependencies established by the methods in possible target classes. We evaluated our approach using systems from a compiled version of the Qualitas Corpus. We report that our approach provides an average precision of 60.63% and an average recall of 81.07%. Such results are, respectively, 129% and 49% better than the results achieved by JDeodorant, a well known move method recommendation system.

ASERG, DCC, UFMG

October 14, 2013
Tweet

More Decks by ASERG, DCC, UFMG

Other Decks in Research

Transcript

  1. Recommending Move Method Refactorings using Dependency Sets Vitor Sales, Ricardo

    Terra, Luis Miranda, Marco Tulio Valente 1 WCRE, Koblenz, Germany, October 2013
  2. Recommendation Algorithm  Main algorithm: Input: method m, and class

    C for each class C’ if similarity (m, C’) > similarity(m,C) then C’ is a candidate to receive M 3
  3. Recommendation Algorithm  Main algorithm: Input: method m, and class

    C for each class C’ if similarity (m, C’) > similarity(m,C) then C’ is a candidate to receive M  How to calculate similarity (m, C)? 4
  4. Method-Method Similarity  Similarity of the dependency sets of each

    method  Deps(m):  classes of the methods called by m  classes of the fields acessed by m  classes of the objects created by m  return type of m  annotations used by m  etc 7
  5. Method Similarity Function  meth_sim(m1 ,m2 )= similarity (Deps(m1 ),

    Deps(m2 ))  Which set similarity coefficient should we use?  Jaccard, Simple Matching, Yule etc 9
  6. Exploratory Study  System: JHotDraw  Assumption:  all methods

    implemented in the correct class  Best coefficient:  The one that generates few recommendations 10
  7. Evaluation  Comparison with JDeodorant:  N. Tsantalis and A.

    Chatzigeorgiou, “Identification of move method refactoring opportunities” IEEE TSE, 2009  How does JMove compares with JDeodorant in terms of  Precision  Recall 15
  8. Gold Sets  We manually moved 475 methods to new

    classes  Source methdods and target classes randonly selected 17
  9. Gold Sets  We manually moved 475 methods to new

    classes  Source methdods and target classes randonly selected  High chances they are located in the wrong classes 18
  10. Gold Sets  We manually moved 475 methods to new

    classes  Source methdods and target classes randonly selected  High chances they are located in the wrong classes 19
  11. Precision 20  Only for JHotDraw (5 instances)  Recs

    not in GoldSets → False positives  In the other systems, we do not know
  12. Precision 21  Only for JHotDraw (5 instances)  Recs

    not in GoldSets → False positives  In the other systems, we do not know
  13. Precision 22  Only for JHotDraw (5 instances)  Recs

    not in GoldSets → False positives  In the other systems, we do not know
  14. Precision 23  Only for JHotDraw (5 instances)  Recs

    not in GoldSets → False positives  In the other systems, we do not know
  15. Recall 24  recall1 : method and target class recommended

    correctly  recall2 : only method recommended correctly
  16. Recall 25  recall1 : method and target class recommended

    correctly  recall2 : only method recommended correctly
  17. Recall 26  recall1 : method and target class recommended

    correctly  recall2 : only method recommended correctly
  18. Conclusion  Approach for move method recommendations  Based on

    the similarity of dependency sets  Evaluation with 475 feature-envy instances:  precision: 60%, recall: 81% 28
  19. Conclusion  Approach for move method recommendations  Based on

    the similarity of dependency sets  Evaluation with 475 feature-envy instances:  precision: 60%, recall: 81%  Dowload: http://aserg.labsoft.dcc.ufmg.br/jmove 29
  20. Conclusion  Approach for move method recommendations  Based on

    the similarity of dependency sets  Evaluation with 475 feature-envy instances:  precision: 60%, recall: 81%  Dowload: http://aserg.labsoft.dcc.ufmg.br/jmove  Ongoing work:  Comparison with other tools (metrics-based)  Evaluation with real systems 30
  21. Thanks! Recommending Move Method Refactorings using Dependency Sets Vitor Sales,

    Ricardo Terra, Luis Miranda, Marco Tulio Valente 31 WCRE, Koblenz, Germany, October 2013