Precise and Complete Requirements? An Elusive Goal
PhD Symposium 2014
1. Detecting and Removing Bad Code
Smells from Source Code
A review of my first PhD year
Fabio Palomba
PhD Symposium 2014
2.
3.
4.
5.
6. Technical Debt is...
“Not quite right code which we
postpone making it right.”
W. Cunningham
7. Technical Debt is...
“Not quite right code which we
postpone making it right.”
W. Cunningham
Low Internal Quality
Documentation Debt
Coding Style Violation
Code Smell
Test debt
Architectural Debt Structural Debt
Code Complexity
15. [Banker et al. Comm. of the ACM 1993]
Bad smells increase
maintenance costs
16. F. Palomba, A. De Lucia, G. Bavota, R. Oliveto.
“Anti-Pattern Detection: Methods, Challanges, and Open Issues”
Advances in Computers, vol. 95 (to appear)
24. HISTChange History Extractor
log download code analyzer
Historical Information
for Smell deTection
method
getUser
has been
added
25. HISTChange History Extractor
log download code analyzer
Historical Information
for Smell deTection
method
getUser
has been
added
method
getData
has been
modified
26. HISTChange History Extractor
log download code analyzer
Historical Information
for Smell deTection
method
getUser
has been
added
method
getData
has been
modified
method
getLogin
has been
moved
27. HISTChange History Extractor
log download code analyzer
Historical Information
for Smell deTection
method
getUser
has been
added
method
getData
has been
modified
method
getLogin
has been
moved
class
User
has been
added
28. HISTChange History Extractor
log download code analyzer
Historical Information
for Smell deTection
method
getUser
has been
added
method
getData
has been
modified
method
getLogin
has been
moved
class
User
has been
added
...
...
...
...
29. HISTChange History Extractor
log download code analyzer
Code Smells Detector
Historical Information
for Smell deTection
method
getUser
has been
added
method
getData
has been
modified
method
getLogin
has been
moved
class
User
has been
added
...
...
...
...
30. HISTChange History Extractor
log download code analyzer
Code Smells Detector
Historical Information
for Smell deTection
method
getUser
has been
added
method
getData
has been
modified
method
getLogin
has been
moved
class
User
has been
added
...
...
...
...
Association rule
discovery to capture co-changes
between entities
31. HISTChange History Extractor
log download code analyzer
Code Smells Detector
Historical Information
for Smell deTection
method
getUser
has been
added
method
getData
has been
modified
method
getLogin
has been
moved
class
User
has been
added
...
...
...
...
Association rule
discovery to capture co-changes
between entities
Analysis of change
frequency of some
specific entities
32. HISTCode Smell Detector
Five different smells considered
Divergent Change
Shotugun Surgery
Parallel Inheritance
Historical Information
for Smell deTection
33. HISTCode Smell Detector
Five different smells considered
Three code smells, by definition,
to consider as “historical” smells
Divergent Change
Shotugun Surgery
Parallel Inheritance
Historical Information
for Smell deTection
34. HISTCode Smell Detector
Five different smells considered
Three code smells, by definition,
to consider as “historical” smells
Divergent Change
Shotugun Surgery
Parallel Inheritance
Blob
Feature Envy
Historical Information
for Smell deTection
35. HISTCode Smell Detector
Five different smells considered
Three code smells, by definition,
to consider as “historical” smells
Divergent Change
Shotugun Surgery
Parallel Inheritance
Two code smells generally
detected by structural analysis,
where the historical analysis can
aid in the identification of
complementary information
Blob
Feature Envy
Historical Information
for Smell deTection
37. Code Smells Detector
divergent change
A class is changed in different
ways for different reasons
38. Code Smells Detector
divergent change
A class is changed in different
ways for different reasons
Solution:
Extract Class Refactoring
39. Code Smells Detector
divergent change
A class is changed in different
ways for different reasons
Solution:
Extract Class Refactoring
Detection
Classes containing at least two sets of methods
such that:
(i) all methods in the set change together as
detected by the association rules
(ii) each method in the set does not change with
methods in other sets
41. Code Smells Detector
blob
A class implementing several
responsibilities, having a large size,
and dependencies with data classes
42. Code Smells Detector
blob
A class implementing several
responsibilities, having a large size,
and dependencies with data classes
Solution:
Extract Class refactoring
43. Code Smells Detector
blob
A class implementing several
responsibilities, having a large size,
and dependencies with data classes
Solution:
Extract Class refactoring
Detection
Blobs are identified as classes frequently modified in
commits involving at least another class.
t1 t2 t3 t4 t5 t6 t7 t8 t9
46. Evaluation
detection accuracy
Comparing HIST with static code
analysis technique on a manually
built oracle
20 open source
systems
47. Evaluation
detection accuracy
20 open source
systems
Shotgun Surgery
Parallel Inheritance
Divergent Change
Blob
Feature Envy
Comparing HIST with static code
analysis technique on a manually
built oracle
HIST F-Measure CA technique F-Measure
92%
71%
82%
64%
77%
0%
9%
11%
48%
68%
48. Evaluation
detection accuracy
Comparing HIST with static code
analysis technique on a manually
built oracle
HIST and
the CA techniques
20 open source
systems
are highly complementary
49. F. Palomba, G. Bavota, M. Di Penta, R. Oliveto, A. De Lucia, and D. Poshyvanyk.
“Detecting Bad Smells in Source Code using Change History Information” - Distinguished Paper Award
International Conference on Automated Software Engineering (ASE 2013)
50. F. Palomba, G. Bavota, M. Di Penta, R. Oliveto, A. De Lucia, and D. Poshyvanyk.
“Detecting Bad Smells in Source Code using Change History Information” - Distinguished Paper Award
International Conference on Automated Software Engineering (ASE 2013)
51. F. Palomba, G. Bavota, M. Di Penta, R. Oliveto, D. Poshyvanyk and A. De Lucia.
“Mining Version Histories for Detecting Code Smells”
Transactions on Software Engineering (TSE) - 2015
52. http://www.sesa.unisa.it/landfill
F. Palomba, D. Di Nucci, M. Tufano, G. Bavota, M. Di Penta, R. Oliveto, D. Poshyvanyk and A. De Lucia.
“Landfill: an Open Dataset of Code Smells with Public Evaluation”
Submitted to the International Conference on Software Engineering (ICSE 2015)
53. HIST
Mar
16 The tool is coming soon...
Historical Information
for Smell deTection
54. Do They Really Smell Bad?
A Study on Developers’ Perception of
Bad Code Smells
Fabio Palomba, Gabriele Bavota, Massimiliano Di Penta,
Rocco Oliveto, Andrea De Lucia
ICSME 2014
Victoria - Canada
October 1st, 2014
55. “We don’t see things as they are,
we see things as we are”
Anais Nin
57. RQ1: To what extent do bad smells reflect developers‘
perception of design problems?
Investigating the
developers’ point of view
58. RQ1: To what extent do bad smells reflect developers‘
perception of design problems?
RQ2: What are the bad smells that developers feel
as the most harmful?
Investigating the
developers’ point of view
59. Smells generally not Perceived as
Design or Implementation Problems
THEORical
problems
61. Smells whose Perception may Var y
dependently by Their Intensit y
THEY SHOULD BE
studied more
62. On the Innate Relationship between
Quality and Refactoring
63. Refactoring is...
“Refactoring is a disciplined technique for restructuring an
existing body of code, improving its non-functional
attributes without changing its external behavior.”
64. 3 open source
systems
Studying if quality metrics
/ bad smells capture
refactoring operations
65. 3 open source
systems
11 quality metrics
Studying if quality metrics
/ bad smells capture
refactoring operations
66. 3 open source
systems
11 quality metrics
11 bad smells
Studying if quality metrics
/ bad smells capture
refactoring operations
67. 3 open source
systems
11 quality metrics
11 bad smells
12,922 refactoring operations
manually validated
Studying if quality metrics
/ bad smells capture
refactoring operations
68. G. Bavota, A. De Lucia, M. Di Penta, R. Oliveto and F. Palomba.
“An Experimental Investigation on the Innate Relationship between Quality and Refactoring”
Submitted to Transactions on Software Engineering and Methodology (TOSEM)
69. http://www.sesa.unisa.it/tools/aries.jsp
F. Palomba, M. Tufano, G. Bavota, R. Oliveto, A. Marcus, D. Poshyvanyk, and A. De Lucia.
“Extract Package Refactoring in ARIES”
Submitted to the International Conference on Software Engineering (ICSE 2015)
71. M. Tufano, F. Palomba, G. Bavota, R. Oliveto, M. Di Penta, A. De Lucia, and D. Poshyvanyk
“When and Why Your Code Starts to Smell Bad”
Submitted to the International Conference on Software Engineering (ICSE 2015)
72. F. Palomba
“Textual Analysis for Code Smell Detection”
Submitted to the International Conference on Software Engineering (ICSE 2015)
74. Technical Debt is...
“Not quite right code which we
postpone making it right.”
W. Cunningham
Low Internal Quality
Documentation Debt
Coding Style Violation
Code Smell
Test debt
Architectural Debt Structural Debt
Code Complexity