Recommending Move Method Refactorings Using Dependency Sets (WCRE 2013)

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.

13beaa3b7239eca3319d54c6a9f3a85a?s=128

ASERG, DCC, UFMG

October 14, 2013
Tweet

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. Introduction  “Move method” recommendation system  Recommendations based on

    dependency sets 2
  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 3
  4. 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
  5. Method-Class Similarity  5

  6. Method-Class Similarity  6

  7. 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
  8. Method Similarity Function  meth_sim(m1 ,m2 )= similarity (Deps(m1 ),

    Deps(m2 )) 8
  9. 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
  10. Exploratory Study  System: JHotDraw  Assumption:  all methods

    implemented in the correct class  Best coefficient:  The one that generates few recommendations 10
  11. # Recommendations, JHotDraw 11

  12. # Recommendations, JHotDraw 12

  13. Best Coefficient  Soakal and Sneath 2: 13

  14. Tool Support: JMove 14

  15. 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
  16. Target Systems  15 systems (qualitas.class) 16

  17. Gold Sets  We manually moved 475 methods to new

    classes  Source methdods and target classes randonly selected 17
  18. 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
  19. 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
  20. Precision 20  Only for JHotDraw (5 instances)  Recs

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

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

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

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

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

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

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

    the similarity of dependency sets 27
  28. Conclusion  Approach for move method recommendations  Based on

    the similarity of dependency sets  Evaluation with 475 feature-envy instances:  precision: 60%, recall: 81% 28
  29. 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
  30. 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
  31. Thanks! Recommending Move Method Refactorings using Dependency Sets Vitor Sales,

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