do they really smell bad? a study on developers' perception of bad code smells
DESCRIPTION
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.TRANSCRIPT
Do They Really Smell Bad? A Study on Developers’ Perception of Bad Code SmellsFabio Palomba, Gabriele Bavota, Massimiliano Di Penta, Rocco Oliveto, Andrea De Lucia
ICSME 2014Victoria - CanadaOctober 1st, 2014
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
Context
Bad Code Smells
giovedì 2 ottobre 14
Bad Code Smells
giovedì 2 ottobre 14
Moha et al., “DECOR: A Method for the Specification and Detection of Code and Design Smells” - TSE 2010
giovedì 2 ottobre 14
van Emden et al., “Java Quality Assurance by Detecting Code Smells” - WCRE 2002
giovedì 2 ottobre 14
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
Kessentini et al., “Deviance from Perfection is a Better Criterion than Closeness to Evil when Identifying Risky Code” - ASE 2010
giovedì 2 ottobre 14
Palomba et al., “Detecting Bad Smells in Source Code using Change History Information” - ASE 2013
giovedì 2 ottobre 14
Abebe et al., “Lexicon Bad Smells in Software” - WCRE 2009
giovedì 2 ottobre 14
Not only detection techniques! But also...
giovedì 2 ottobre 14
A. Chatzigeorgiou et al., “Investigating the evolution of bad smells in object-oriented code” - QUATIC 2010
giovedì 2 ottobre 14
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
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
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
“We don’t see things as they are, we see things as we are” Anais Nin
giovedì 2 ottobre 14
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
A. Yamashita and L. Moonen, “Do developers care about code smells? An exploratory survey” - WCRE 2013
giovedì 2 ottobre 14
Investingating the developers’ point of view
giovedì 2 ottobre 14
RQ1: To what extent do bad smells reflect developers’ perception of design problems?
Investingating the developers’ point of view
giovedì 2 ottobre 14
RQ1: To what extent do bad smells reflect developers’ perception of design problems?
Investingating the developers’ point of view
RQ2: What are the bad smells that developers feel as the most harmful?
giovedì 2 ottobre 14
Study Design
giovedì 2 ottobre 14
Study DesignClass Data Should Be Private
Complex ClassFeature Envy
God ClassInappropriate Intimacy
Lazy ClassLong Method
Long Parameter ListMiddle Man
Refused BequestSpaghetti Code
Speculative Generality
giovedì 2 ottobre 14
Study DesignClass Data Should Be Private
Complex ClassFeature Envy
God ClassInappropriate Intimacy
Lazy ClassLong Method
Long Parameter ListMiddle Man
Refused BequestSpaghetti Code
Speculative Generality
Argo UML 0.34Eclipse 3.6.1
jEdit 4.5.1
giovedì 2 ottobre 14
Study Design
Original Developers: 10
Industrial Developers9
Master’s Students15
Argo UML 0.34Eclipse 3.6.1
jEdit 4.5.1
Class Data Should Be PrivateComplex Class
Feature EnvyGod Class
Inappropriate IntimacyLazy Class
Long MethodLong Parameter List
Middle ManRefused BequestSpaghetti Code
Speculative Generality
giovedì 2 ottobre 14
Study Design
Smelly Class
Developer
giovedì 2 ottobre 14
Study Design
Smelly Class
Developer
In your opinion, does this code component exhibit any design and/or implementation problem?
giovedì 2 ottobre 14
Study Design
Smelly Class
Developer
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
Study Design
Smelly Class
Developer
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
Resultsgiovedì 2 ottobre 14
Smells generally not Perceived as Design or Implementation Problems
Class Data Should Be Private
Middle Man
Lazy Class
Inappropriate Intimacy
Long Parameter List
giovedì 2 ottobre 14
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
Smells generally not Perceived as Design or Implementation Problems
Class Data Should Be Private < 25% perceived < 24% IDENTIFIED
0
5
10
15
20
25
30
M I O
Identified Perceived
giovedì 2 ottobre 14
Smells generally not Perceived as Design or Implementation Problems
Class Data Should Be Private < 25% perceived < 24% IDENTIFIED
0
5
10
15
20
25
30
M I O
Identified Perceived
M I O
Severity
1 2 2
giovedì 2 ottobre 14
Smells generally not Perceived as Design or Implementation Problems
Class Data Should Be Private < 25% perceived < 24% IDENTIFIED
0
5
10
15
20
25
30
M I O
Identified Perceived
M I O
Severity
“This class exposes all its fields, and this could look like bad coding.
However, at the end of the day this is an utility class with public static
fields that can be used from everywhere in the system”
giovedì 2 ottobre 14
Smells generally Perceived and Identified by Respondents
Complex Class
God Class
Long Method
Spaghetti Code
giovedì 2 ottobre 14
Smells generally Perceived and Identified by Respondents
Complex Class
God 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
Smells generally Perceived and Identified by Respondents
God Class
0
17
33
50
67
83
100
M I O
Identified Perceived
> 85% perceived > 83% IDENTIFIED
giovedì 2 ottobre 14
Smells generally Perceived and Identified by Respondents
God Class
0
17
33
50
67
83
100
M I O
Identified Perceived
M I O
Severity
> 85% perceived > 83% IDENTIFIED
4 5 5
giovedì 2 ottobre 14
Refused Bequest
Smells whose Perception may vary
Speculative Generality
Feature Envy
giovedì 2 ottobre 14
Refused Bequest
Smells whose Perception may vary
Speculative Generality
Feature Envy
DEPENDS FROM
THE “INTENSITY” OF
THE PROBLEM
giovedì 2 ottobre 14
Smells whose Perception may vary
Refused Bequest
0102030405060708090
100
ArgoUML Eclipse jEdit
Perceived Identified
Master Students Perception on the Three Analyzed Systems
giovedì 2 ottobre 14
Smells whose Perception may vary
Refused Bequest Master Students Perception on the Three Analyzed Systems
0102030405060708090
100
ArgoUML Eclipse jEdit
Perceived Identified
1
1
4
giovedì 2 ottobre 14
Conclusion
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
giovedì 2 ottobre 14
?giovedì 2 ottobre 14