In the last decade several catalogues have been defined to characterize bad code smells, i.e., symptoms of poor design and implementation choices. On top of such catalogues, researchers have defined methods and tools to automatically detect and/or remove bad smells. Nevertheless, there is an ongoing debate regarding the extent to which developers perceive bad smells as serious design problems. Indeed, there seems to be a gap between theory and practice, i.e., what is believed to be a problem (theory) and what is actually a problem (practice). This paper presents a study aimed at providing empirical evidence on how developers perceive bad smells. In this study, we showed to developers code entities—belonging to three systems— affected and not by bad smells, and we asked them to indicate whether the code contains a potential design problem, and if any, the nature and severity of the problem. The study involved both original developers from the three projects and outsiders, namely industrial developers and Master students. The results provide insights on characteristics of bad smells not yet explored sufficiently. Also, our findings could guide future research on approaches for the detection and removal of bad smells.
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Do They Really Smell Bad? A Study on Developers' Perception of Bad Code Smells
1. 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
giovedì 2 ottobre 14
8. Moha et al., “DECOR: A Method for the Specification and Detection of
Code and Design Smells” - TSE 2010
giovedì 2 ottobre 14
9. van Emden et al., “Java Quality Assurance by Detecting Code Smells” -
WCRE 2002
giovedì 2 ottobre 14
10. Tsantalis et al., “Identification of Move Method Refactoring
Opportunities” - TSE 2009
Fokaets et al., “Identification and Application of Extract Class
Refactorings In Object Oriented Systems” - JSS 2012
Tsantalis et al., “Identification of Extract Method Refactoring
Opportunities for the Decomposition of Methods” - JSS 2011
giovedì 2 ottobre 14
11. Kessentini et al., “Deviance from Perfection is a Better Criterion than
Closeness to Evil when Identifying Risky Code” - ASE 2010
giovedì 2 ottobre 14
12. Palomba et al., “Detecting Bad Smells in Source Code using Change
History Information” - ASE 2013
giovedì 2 ottobre 14
13. Abebe et al., “Lexicon Bad Smells in Software” - WCRE 2009
giovedì 2 ottobre 14
15. A. Chatzigeorgiou et al., “Investigating the evolution of bad smells in
object-oriented code” - QUATIC 2010
giovedì 2 ottobre 14
16. R. Peters and A. Zaidman, “Evaluating the lifespan of code smells using
software repository mining” - CSMR 2012
R. Arcoverde, A. Garcia, and E. Figueiredo, “Understanding the longevity of
code smells: preliminary results of an explanatory survey” - IWRT 2011
giovedì 2 ottobre 14
17. F. Khomh, M. Di Penta, Y.-G. Guéhéneuc, and G. Antoniol, “An exploratory study of the impact of
antipatterns on class change- and fault-proneness” - EMSE 2012
W. Li and R. Shatnawi, “An empirical study of the bad smells and class error probability in the post-release
object-oriented system evolution” - JSS 2007
giovedì 2 ottobre 14
18. M. Abbes, F. Khomh,Y.-G. Guéhéneuc, and G. Antoniol, “An empirical study of the impact
of two antipatterns, blob and spaghetti code, on program comprehension” - CSMR 2011
giovedì 2 ottobre 14
19. “We don’t see things as they are,
we see things as we are”
Anais Nin
giovedì 2 ottobre 14
20. S. M. Olbrich, D. S. Cruzes, and D. I. K. Sjøberg, “Are all code smells harmful? A study of
God Classes and Brain Classes in the evolution of three open source systems” - ICSM 2010
giovedì 2 ottobre 14
21. A. Yamashita and L. Moonen, “Do developers care about code smells? An exploratory
survey” - WCRE 2013
giovedì 2 ottobre 14
23. Investingating the
developers’ point of view
RQ1: To what extent do bad smells reflect
developers’ perception of design problems?
giovedì 2 ottobre 14
24. Investingating the
developers’ point of view
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?
giovedì 2 ottobre 14
26. Study Design
Class Data Should Be Private
Complex Class
Feature Envy
God Class
Inappropriate Intimacy
Lazy Class
Long Method
Long Parameter List
Middle Man
Refused Bequest
Spaghetti Code
Speculative Generality
giovedì 2 ottobre 14
27. Study Design
Class Data Should Be Private
Complex Class
Feature Envy
God Class
Inappropriate Intimacy
Lazy Class
Long Method
Long Parameter List
Middle Man
Refused Bequest
Spaghetti Code
Speculative Generality
Argo UML 0.34
Eclipse 3.6.1
jEdit 4.5.1
giovedì 2 ottobre 14
28. Study Design
Argo UML 0.34
Eclipse 3.6.1
jEdit 4.5.1
Original Developers:
10
Industrial Developers
9
Master’s Students
15
Class Data Should Be Private
Complex Class
Feature Envy
God Class
Inappropriate Intimacy
Lazy Class
Long Method
Long Parameter List
Middle Man
Refused Bequest
Spaghetti Code
Speculative Generality
giovedì 2 ottobre 14
30. Study Design
Developer
Smelly Class
In your opinion, does this code
component exhibit any design and/or
implementation problem?
giovedì 2 ottobre 14
31. Study Design
Developer
Smelly Class
In your opinion, does this code
component exhibit any design and/or
implementation problem?
• If YES, please explain what are, in your
opinion, the problems affecting the code
component.
giovedì 2 ottobre 14
32. Study Design
Developer
Smelly Class
In your opinion, does this code
component exhibit any design and/or
implementation problem?
• If YES, please explain what are, in your
opinion, the problems affecting the code
component.
• If YES, please rate the severity of the
design and/or implementation problem
by assigning a score on the following five-points
Likert scale: 1 (very low), 2 (low),
3 (medium), 4 (high), 5 (very high).
giovedì 2 ottobre 14
34. Smells generally not Perceived as
Design or Implementation Problems
Class Data Should Be Private
Middle Man
Long Parameter List
Lazy Class
Inappropriate Intimacy
giovedì 2 ottobre 14
35. Smells generally not Perceived as
Design or Implementation Problems
Class Data Should Be Private
Middle Man
Lazy Class
Inappropriate Intimacy
< 25% perceived < 24% IDENTIFIED
< 10% perceived < 5% IDENTIFIED
< 36% PERCEIVED
< 20% PERCEIVED
< 30% PERCEIVED
< 20% IDENTIFIED
< 5% IDENTIFIED
< 13% IDENTIFIED
Long Parameter List
giovedì 2 ottobre 14
36. Smells generally not Perceived as
Design or Implementation Problems
Class Data Should Be Private < 25% perceived < 24% IDENTIFIED
30
25
20
15
10
5
0
M I O
Identified Perceived
giovedì 2 ottobre 14
37. Smells generally not Perceived as
Design or Implementation Problems
Class Data Should Be Private < 25% perceived < 24% IDENTIFIED
30
25
20
15
10
5
0
M I O
Identified Perceived
Severity
M I O
1 2 2
giovedì 2 ottobre 14
38. Smells generally not Perceived as
Design or Implementation Problems
Class Data Should Be Private < 25% perceived < 24% IDENTIFIED
30
25
“This 20
class exposes all its fields, and this could look like bad coding.
However, 15
at the end of the day this is an utility class with public static
10
5
0
M I O
Identified Perceived
Severity
M I O
fields that can be used from everywhere in the system”
giovedì 2 ottobre 14
39. Smells generally Perceived and
Identified by Respondents
God Class
Complex Class
Long Method
Spaghetti Code
giovedì 2 ottobre 14
40. Smells generally Perceived and
Identified by Respondents
God Class
Complex Class
Long Method
Spaghetti Code
> 85% perceived > 83% IDENTIFIED
> 75% perceived > 75% IDENTIFIED
> 70% perceived > 70% IDENTIFIED
> 68% perceived < 65% IDENTIFIED
giovedì 2 ottobre 14
41. Smells generally Perceived and
Identified by Respondents
God Class
100
83
67
50
33
17
0
M I O
Identified Perceived
> 85% perceived > 83% IDENTIFIED
giovedì 2 ottobre 14
42. Smells generally Perceived and
Identified by Respondents
God Class
100
83
67
50
33
17
0
M I O
Identified Perceived
> 85% perceived > 83% IDENTIFIED
Severity
M I O
4 5 5
giovedì 2 ottobre 14
43. Smells whose Perception may vary
Refused Bequest
Feature Envy
Speculative Generality
giovedì 2 ottobre 14
44. Smells whose Perception may vary
Refused Bequest
Feature Envy
Speculative Generality
DEPENDS FROM
THE “INTENSITY” OF
THE PROBLEM
giovedì 2 ottobre 14
45. Smells whose Perception may vary
Refused Bequest
100
90
80
70
60
50
40
30
20
10
0
Master Students Perception on the Three Analyzed Systems
ArgoUML Eclipse jEdit
Perceived Identified
giovedì 2 ottobre 14
46. Smells whose Perception may vary
Refused Bequest Master Students Perception on the Three Analyzed Systems
100
90
80
70
60
50
40
30
20
10
0
ArgoUML Eclipse jEdit
Perceived Identified
1
1
4
giovedì 2 ottobre 14