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

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.

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

    View Slide

  2. Introduction
     “Move method” recommendation system
     Recommendations based on dependency sets
    2

    View Slide

  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

    View Slide

  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

    View Slide

  5. Method-Class Similarity

    5

    View Slide

  6. Method-Class Similarity

    6

    View Slide

  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

    View Slide

  8. Method Similarity Function
     meth_sim(m1
    ,m2
    )=
    similarity (Deps(m1
    ), Deps(m2
    ))
    8

    View Slide

  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

    View Slide

  10. Exploratory Study
     System: JHotDraw
     Assumption:
     all methods implemented in the correct class
     Best coefficient:
     The one that generates few recommendations
    10

    View Slide

  11. # Recommendations, JHotDraw
    11

    View Slide

  12. # Recommendations, JHotDraw
    12

    View Slide

  13. Best Coefficient
     Soakal and Sneath 2:
    13

    View Slide

  14. Tool Support: JMove
    14

    View Slide

  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

    View Slide

  16. Target Systems
     15 systems (qualitas.class)
    16

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  31. Thanks!
    Recommending Move Method Refactorings
    using Dependency Sets
    Vitor Sales, Ricardo Terra, Luis Miranda, Marco Tulio Valente
    31
    WCRE, Koblenz, Germany, October 2013

    View Slide