Natthawute Sae-Lim, Shinpei Hayashi, and Motoshi Saeki

Department of Computer Science
Tokyo Institute of Technology

INTRODUCTION

2

Code smell[1]An indicator of a design flaw or a problem
in the source code
One of the factors that cause technical debt
Increases code component’s fault-proneness

Refactoring
Duplicated Code(Extract Method)[1] M. Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley, 1999.

3

Problem

The number ofcode smell isoverwhelming4Code Smells Prioritization[MTD 2015][J. ASE 2016]

An Approach to Prioritize
Code Smells for Refactoring
Vidal et al.

Towards a Prioritization ofCode Debt: A Code Smell
Intensity Index
Fontana et al.

[ICPC 2016]

Context-Based Code Smells
Prioritization for Prefactoring
Sae-Lim et al.

[SBSE 2013]

Prioritization of CodeAnomalies based on
Architecture Sensitiveness[ICSE 2016]

Technical Debt Prioritization
using Predictive Analytics
Codabux et al.

Arcoverde et al.
5

CONTEXT-BASED CODE SMELLSPRIORITIZATION
6

Problem
Code smell detection results
Blob

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

Method B(){_______________}. . .

Blobth50

Method A(){__________}

Relevant !

. . .

100th Blob

Method C(){_____}

Problem :Results from existing smell detector
do not fit in this situation
7

Goal
Original code smell
detection result

Proposed code smell
detection result

1st

1st

2nd

2nd

3rd

3rd

Our technique
. . .

. . .

nthnthSmells that are relevant to developers’ context
8

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

9

Empirical StudyjEdit
JabRefArgoUML

Prioritize

1…
2…
3…

Prioritized smells

Code smells

muCommander
CompareConclusion
Our technique can prioritizecode smells occurring in themodules that are going to bemodifiedVCS
Modificationbased oracle
Code smells

10Software change process[1]Interaction History

Initiation
Concept Location
Impact Analysis

Version Control System

Identify amodule to bemodified
Identify a full setof modules to bemodified

Referred
Modules

Prefactoring
Actualization

Modify source
code

Modified
Modules

Postfactoring
Conclusion[1] V. Rajlich, Software Engineering: The Current Practice. Chapman and Hall/CRC, 201111

Mylyn
Task and application lifecycle management (ALM)
framework for Eclipse.

12MylynDeveloper selects text in editor<InteractionEvent
Delta="null"
EndDate="2009-09-08 18:34:51.838 PDT"Interest="1.0"
Kind="edit"
Navigation="null"
OriginId="org.eclipse.jdt.ui.CompilationUnitEditor"
StartDate="2009-09-08 18:34:51.838 PDT"
StructureHandle="=org.eclipse.mylyn.internal.context.
ui{IContextUiHelpIds.java"
StructureKind="java”/>
13Software change process[1]Interaction History

Initiation
Concept Location
Impact Analysis

Version Control System

Identify amodule to bemodified
Identify a full setof modules to bemodified

Prefactoring
Actualization

Modify source
code?
Referred
Modules✓Modified
Modules

Postfactoring
Conclusion[1] V. Rajlich, Software Engineering: The Current Practice. Chapman and Hall/CRC, 201114

Software change process[1]Interaction History

Initiation
Identify amodule to bemodified?

Is our technique✓useful forreferred context?
Concept Location
Impact Analysis

Version Control System

Identify a full setof modules to bemodified

Referred
Modules

Prefactoring

Actualization

Modify source
code

Modified
Modules

Postfactoring
Conclusion[1] V. Rajlich, Software Engineering: The Current Practice. Chapman and Hall/CRC, 201115

EMPIRICAL STUDY

16

Overview
Subject: Mylyn Task 3.07-3.21
1…
2…
3…

Prioritized smells
CompareCompareVCS
Modificationbased oracleCode smells

Referencebased oracle

InteractionHistory

Code smells

17ResultuIs our technique useful for referred modules?
1nDCG

0.8

0.66

0.78

0.6
0.4
0.2
0
Modification-based

Reference-based

Our technique can be useful to support bothmodified modules and referred modules
18Top 10 results
Rank

Smell TypeClass Name

#RI

#MI

1

God

TasksUiInternal

742

God

TasksUiPlugin

933GodTaskListIndex

314

God

AbstractTaskEditorPage

325GodTaskDataManager

426GodTracRepositoryConnector

117GodAttachmentUtil

418GodSynchronizeTasksJob

309

Data

TaskData

3010

God

BugzillaRepositoryConnector

02#RI = Number of referring issues#MI = Number of modifying issues
19CONCLUSION

20

Messages

Context-based code smells prioritization
Modified Context

Referred Context

Can support both types of context

21