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 full-size slide

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

    View full-size 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 full-size 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 full-size slide

  5. Method-Class Similarity

    5

    View full-size slide

  6. Method-Class Similarity

    6

    View full-size 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 full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

  11. # Recommendations, JHotDraw
    11

    View full-size slide

  12. # Recommendations, JHotDraw
    12

    View full-size slide

  13. Best Coefficient
     Soakal and Sneath 2:
    13

    View full-size slide

  14. Tool Support: JMove
    14

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size 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 full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size 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 full-size 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 full-size 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 full-size slide