Natthawute Sae-Lim, Shinpei Hayashi, and Motoshi Saeki

Department of Computer Science
Tokyo Institute of Technology

INTRODUCTION

2Prefactoring[1]BlobMethod A(){________________________}

Refactoring

Method A(){________}
I need to implement
feature X
in method A()

Difficult

Easier !

(´･_･`)（＾∇＾）[1] V. Rajlich, Software Engineering: The Current Practice. Chapman and Hall/CRC, 20113

Problem
Code smell detection results
Blob

1stI need to implement
feature X
in method A()

Method B(){_______________}. . .

Blob
th50

Method A(){__________}

Relevant !

. . .

100th Blob

Method C(){_____}

Problem :Results from existing smell detector
do not fit prefactoring phase4

Goal
Original code smell
detection result

Proposed code smell
detection result

1st

1st

2nd

2nd

3rd

3rd

Our technique
. . .

. . .

nth

nth
Smells that are relevant to developers’ context
5

Key Idea
Severity-basedprioritization[1][2]Context-basedprioritization

1st

1st

2nd

2nd

3rd

3rd. . .

. . .
nth

I need to improveoverall quality ofthe source code

I need to implement
feature Xin method A()

nth[1] R. Marinescu, “Assessing technical debt by identifying design flaws in software systems,” IBM Journal of Research and Development, 2012
6
[2] F. A. Fontana, V. Ferme, M. Zanoni, and R. Roveda, “Towards a Prioritization of Code Debt : A Code Smell Intensity Index, “ MTD2015

PROPOSED TECHNIQUE

7

Developers’ context
uDevelopers’ context = modules to be modified
Open issue #1
Fix a bug in login
page. . .

ITSOpen issue #50
Add “forgot password”
featurenThis list is used to estimate developers’ context
8

Impact analysis
uIdentify modules in source code that are likely tobe affected by the changes
uImpact analysis → Change prediction
Relevant modules

Change description #1

There is a bug in login
page that user can login
successfully if leave thepassword field blank.

LoginPage.login()
LoginPage.Reset()
UserPage.setPassword()
FormField.getPassword()…
UserPage.ShowError()9

Approach overview
Bug 123
Bug 123
BugWhen123
Whenclick…
Whenclick…
click…

Change descriptions

TraceLab[1]Impact analysis[2]Main()xxx;;

Source code

List of modules

Code smell detection

Scoring
List of smells
1…
2…
3…

Prioritized smells[1] B. Dit, E. Moritz, and D. Poshyvanyk, “A TraceLab-based Solution for Creating, Conducting, andSharing Feature Location Experiments,”, ICPC2012[2] https://www.intooitus.com/products/infusion

10

Scoring
uContext Relevance IndexnAccumulating the score of matched modules in IA result
Impact analysis results#1
Relevant modules

Score

FormField.getPassword()

0.5

CRI

LoginPage.login()

0.1

Code smell detection results
SmellLevel

Module

…

…

…

…

…

Blob

MethodLoginPage.login()

0.4

#50

…

…

…

…

Relevant modules

Score

UserPage.Reset()

0.7

LoginPage.login()

0.3

…
11

EMPIRICAL STUDIES

12

Empirical Studies

RQ2 : Does the accuracy of IA affectquality of the ranking ?

RQ3 : Does Context-based smell
prioritization provide more relevant
results than the severity-based one?

13

Subjects
uUse Dit et al.’s benchmark dataset[1]jEdit

JabRefArgoUML

muCommander

Ver. X
37-61 smells

Bug 123
Whenclick…

Bug 123
Whenclick…

Bug 123
Whenclick…

Ver. Y

91-150 Issues[1] Dit, B., Revelle, M., Gethers, M., and Poshyvanyk, D., "Feature Location in Source Code: A Taxonomy and Survey", JSME2011 14

MetricunDCG (Normalized Discounted Cumulative Gain)
Metric for evaluating the quality of ranking documents
n Relevant documents in higher rank are more useful thanthe ones in lower rank
nuCalculate nDCG for:
CRISeverity

VS.

Our
approach

ReorderuOraclenSmells occurring in the modules actually modified during
two releases
15Empirical Studies

RQ2 : Does the accuracy of IA affectquality of the ranking ?

RQ3 : Does Context-based smell
prioritization provide more relevant
results than the severity-based one?

16

RQ2Impact analysis[1]VSM

LSI

VSM+Dyn

LSI+DynCut points

VSM = Vector Space Model
LSI = Latent Semantic Indexing
Dyn = Dynamic Analysis[1] M. Gethers, B. Dit, H. Kagdi, and D. Poshyvanyk, “Integrated impact analysis for
managing software changes,” ICSE2012

510203040
17

RQ2uRQ2: Does the accuracy of impact analysis affectquality of the ranking?
u Spearman’s correlation coefficient
nnDCG

1

Evaluate the association between two variables
11

0.9

0.9

0.9

0.8

0.8

0.8

0.7

0.7

0.7

0.6

0.6

0.6

0.5

0.5

0.5
0.6
00

0.05

0.1

Precisionr = 0.24

0.15

00.2

0.4

Recallr = 0.48

0.05

0.1

0.15

0.2

F-1

r = 0.37

Accuracy of IA tends to affect qualityof the ranking by our technique18

Empirical Studies

RQ2 : Does the accuracy of IA affectquality of the ranking ?

RQ3 : Does Context-based smell
prioritization provide more relevant
results than the severity-based one?

19

RQ3
uRQ3: Does context-based smell prioritization
provide more relevant results than the severitybased one?
1nDCG

0.8
0.6
0.4
0.2
0
ArgoUML

JabRefSeverity-based

jEdit

muCommander

Context-based

YES !
20

RQ3
Baseline

Our approach

Rank

Smell TypeClass Name

Severity

1

Blob

GeneratorCSharp

2

Blob

3

#Issues

Rank

Smell TypeClass Name

CRI

#Issues81

GodProject

7.90

3

GeneratorJava82

God

ProjectBrowser

4.04

7GodFigAssociation

853Blob

ProjectBrowser

4.04

74BlobParserDisplay

814SC

StylePanel

2.43

15BlobGeneratorPHP475God

FigNodeModeIElemen

2.18

46RPB

FigClassifierRole

736GodUMLMutableGraphS

1.54

7Blob

Modeller

717

Blob

GeneratorCSharp

1.04

8SC

Import68God

FigEdgeModelIEleme

0.94

39God

CoreFactoryMDRImpl

59God

ExtensionMechanism

0.91

110

RPB

StylePanelFigText

510GodCoreFactoryMDRImpl

0.80

1121

CONCLUSION

22

Conclusion
Context-based code smells prioritization
Prefactoring

AutomatedAccuracy of IA tends to impact the results
More relevant results than severity-based
23