Recommending Move Method
Refactorings using Dependency Sets
Vitor Sales, Ricardo Terra,
Luis Miranda, Marco Tulio Valente
1
WCRE, Koblenz, Germany, October 2013
Slide 2
Slide 2 text
Introduction
“Move method” recommendation system
Recommendations based on dependency sets
2
Slide 3
Slide 3 text
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
Slide 4
Slide 4 text
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
Slide 5
Slide 5 text
Method-Class Similarity
5
Slide 6
Slide 6 text
Method-Class Similarity
6
Slide 7
Slide 7 text
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
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
Slide 10
Slide 10 text
Exploratory Study
System: JHotDraw
Assumption:
all methods implemented in the correct class
Best coefficient:
The one that generates few recommendations
10
Slide 11
Slide 11 text
# Recommendations, JHotDraw
11
Slide 12
Slide 12 text
# Recommendations, JHotDraw
12
Slide 13
Slide 13 text
Best Coefficient
Soakal and Sneath 2:
13
Slide 14
Slide 14 text
Tool Support: JMove
14
Slide 15
Slide 15 text
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
Slide 16
Slide 16 text
Target Systems
15 systems (qualitas.class)
16
Slide 17
Slide 17 text
Gold Sets
We manually moved 475 methods to new classes
Source methdods and target classes randonly selected
17
Slide 18
Slide 18 text
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
Slide 19
Slide 19 text
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
Slide 20
Slide 20 text
Precision
20
Only for JHotDraw (5 instances)
Recs not in GoldSets → False positives
In the other systems, we do not know
Slide 21
Slide 21 text
Precision
21
Only for JHotDraw (5 instances)
Recs not in GoldSets → False positives
In the other systems, we do not know
Slide 22
Slide 22 text
Precision
22
Only for JHotDraw (5 instances)
Recs not in GoldSets → False positives
In the other systems, we do not know
Slide 23
Slide 23 text
Precision
23
Only for JHotDraw (5 instances)
Recs not in GoldSets → False positives
In the other systems, we do not know
Slide 24
Slide 24 text
Recall
24
recall1
: method and target class recommended correctly
recall2
: only method recommended correctly
Slide 25
Slide 25 text
Recall
25
recall1
: method and target class recommended correctly
recall2
: only method recommended correctly
Slide 26
Slide 26 text
Recall
26
recall1
: method and target class recommended correctly
recall2
: only method recommended correctly
Slide 27
Slide 27 text
Conclusion
Approach for move method recommendations
Based on the similarity of dependency sets
27
Slide 28
Slide 28 text
Conclusion
Approach for move method recommendations
Based on the similarity of dependency sets
Evaluation with 475 feature-envy instances:
precision: 60%, recall: 81%
28
Slide 29
Slide 29 text
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
Slide 30
Slide 30 text
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
Slide 31
Slide 31 text
Thanks!
Recommending Move Method Refactorings
using Dependency Sets
Vitor Sales, Ricardo Terra, Luis Miranda, Marco Tulio Valente
31
WCRE, Koblenz, Germany, October 2013