phd symposium 2014
TRANSCRIPT
![Page 1: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/1.jpg)
Detecting and Removing Bad Code Smells from Source Code
Fabio Palomba
A review of my first PhD year
PhD Symposium 2014
![Page 2: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/2.jpg)
![Page 3: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/3.jpg)
![Page 4: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/4.jpg)
![Page 5: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/5.jpg)
![Page 6: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/6.jpg)
Technical Debt is...“Not quite right code which we
postpone making it right.”
W. Cunningham
![Page 7: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/7.jpg)
Technical Debt is...“Not quite right code which we
postpone making it right.”
W. Cunningham
Documentation DebtCode Smell
Test debt
Coding Style Violation
Structural DebtArchitectural Debt
Low Internal Quality
Code Complexity
![Page 8: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/8.jpg)
Bad Code Smells
![Page 9: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/9.jpg)
![Page 10: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/10.jpg)
[Abbes et al. CSMR 2011]
![Page 11: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/11.jpg)
[Abbes et al. CSMR 2011]
Bad Smells hinder code comprehensibility
![Page 12: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/12.jpg)
[Khomh et al. EMSE 2012]
![Page 13: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/13.jpg)
[Khomh et al. EMSE 2012]
Bad Smells increase change and fault proneness
![Page 14: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/14.jpg)
[Banker et al. Comm. of the ACM 1993]
![Page 15: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/15.jpg)
[Banker et al. Comm. of the ACM 1993]
Bad smells increase maintenance costs
![Page 16: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/16.jpg)
F. Palomba, A. De Lucia, G. Bavota, R. Oliveto. “Anti-Pattern Detection: Methods, Challanges, and Open Issues”
Advances in Computers, vol. 95 (to appear)
![Page 17: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/17.jpg)
Many detection techniques use structural analysis
![Page 18: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/18.jpg)
Many bad smells are intrinsically characterized by how code elements change over time, rather
than by structural properties
![Page 19: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/19.jpg)
HIST
Historical Information for Smell deTection
![Page 20: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/20.jpg)
Historical Information for Smell deTection
HIST
![Page 21: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/21.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
![Page 22: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/22.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
log download
![Page 23: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/23.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
log download code analyzer
![Page 24: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/24.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
log download code analyzer
method getUser has been
added
![Page 25: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/25.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
log download code analyzer
method getUser has been
added
method getData has been modified
![Page 26: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/26.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
log download code analyzer
method getUser has been
added
method getData has been modified
method getLogin has been moved
![Page 27: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/27.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
log download code analyzer
method getUser has been
added
method getData has been modified
method getLogin has been moved
class User
has been added
![Page 28: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/28.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
log download code analyzer
method getUser has been
added
method getData has been modified
method getLogin has been moved
class User
has been added
...
...
...
...
![Page 29: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/29.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
Code Smells Detector
log download code analyzer
method getUser has been
added
method getData has been modified
method getLogin has been moved
class User
has been added
...
...
...
...
![Page 30: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/30.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
Code Smells Detector
log download code analyzer
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
![Page 31: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/31.jpg)
Historical Information for Smell deTection
HISTChange History Extractor
Code Smells Detector
log download code analyzer
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
![Page 32: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/32.jpg)
Historical Information for Smell deTection
HISTCode Smell DetectorFive different smells considered
Divergent ChangeShotugun SurgeryParallel Inheritance
![Page 33: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/33.jpg)
Historical Information for Smell deTection
HISTCode Smell DetectorFive different smells considered
Three code smells, by definition, to consider as “historical” smells
Divergent ChangeShotugun SurgeryParallel Inheritance
![Page 34: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/34.jpg)
Historical Information for Smell deTection
HISTCode Smell DetectorFive different smells considered
Three code smells, by definition, to consider as “historical” smells
Divergent ChangeShotugun SurgeryParallel Inheritance
BlobFeature Envy
![Page 35: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/35.jpg)
Historical Information for Smell deTection
HISTCode Smell DetectorFive different smells considered
Three code smells, by definition, to consider as “historical” smells
Two code smells generally detected by structural analysis, where the historical analysis can aid in the identification of complementary information
Divergent ChangeShotugun SurgeryParallel Inheritance
BlobFeature Envy
![Page 36: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/36.jpg)
Code Smells Detectordivergent change
![Page 37: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/37.jpg)
Code Smells Detectordivergent change
A class is changed in different ways for different reasons
![Page 38: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/38.jpg)
Code Smells Detectordivergent change
A class is changed in different ways for different reasons
Solution: Extract Class Refactoring
![Page 39: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/39.jpg)
Code Smells Detectordivergent change
A class is changed in different ways for different reasons
Solution: Extract Class Refactoring
DetectionClasses 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
![Page 40: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/40.jpg)
Code Smells Detectorblob
![Page 41: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/41.jpg)
Code Smells Detectorblob
A class implementing several responsibilities, having a large size, and dependencies with data classes
![Page 42: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/42.jpg)
Code Smells Detectorblob
A class implementing several responsibilities, having a large size, and dependencies with data classes
Solution: Extract Class refactoring
![Page 43: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/43.jpg)
Code Smells Detectorblob
A class implementing several responsibilities, having a large size, and dependencies with data classes
Solution: Extract Class refactoring
DetectionBlobs are identified as classes frequently modified in commits involving at least another class.
t1 t3t2 t4 t6t5 t7 t9t8
![Page 44: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/44.jpg)
Evaluationdetection accuracy
![Page 45: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/45.jpg)
Evaluationdetection accuracy
20 open source systems
![Page 46: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/46.jpg)
Evaluationdetection accuracy
Comparing HIST with static code analysis technique on a manually
built oracle20 open source
systems
![Page 47: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/47.jpg)
Evaluationdetection accuracy
20 open source systems
Shotgun Surgery
Parallel Inheritance
Divergent Change
Blob
Feature Envy
HIST F-Measure CA technique F-Measure92%
71%
82%
64%
77%
0%
9%
11%
48%
68%
Comparing HIST with static code analysis technique on a manually
built oracle
![Page 48: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/48.jpg)
Evaluationdetection accuracy
HIST and the CA techniques
are highly complementary
20 open source systems
Comparing HIST with static code analysis technique on a manually
built oracle
![Page 49: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/49.jpg)
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)
![Page 50: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/50.jpg)
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)
![Page 51: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/51.jpg)
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
![Page 52: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/52.jpg)
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)
http://www.sesa.unisa.it/landfill
![Page 53: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/53.jpg)
HIST
Historical Information for Smell deTection
Mar
16 The tool is coming soon...
![Page 54: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/54.jpg)
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
![Page 55: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/55.jpg)
“We don’t see things as they are, we see things as we are” Anais Nin
![Page 56: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/56.jpg)
Investigating the developers’ point of view
![Page 57: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/57.jpg)
Investigating the developers’ point of view
RQ1: To what extent do bad smells reflect developers‘
perception of design problems?
![Page 58: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/58.jpg)
Investigating 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?
![Page 59: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/59.jpg)
Smells generally not Perceived as Design or Implementation Problems
THEORical
problems
![Page 60: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/60.jpg)
Smells generally Perceived and Identified by Respondents
THEY SHOULD BE
CAREFULLY ANALYZED
![Page 61: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/61.jpg)
THEY SHOULD BE
studied more
Smells whose Perception may Vary dependently by Their Intensity
![Page 62: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/62.jpg)
On the Innate Relationship between Quality and Refactoring
![Page 63: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/63.jpg)
Refactoring is...“Refactoring is a disciplined technique for restructuring an
existing body of code, improving its non-functional attributes without changing its external behavior.”
![Page 64: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/64.jpg)
Studying if quality metrics / bad smells capture
refactoring operations
3 open source systems
![Page 65: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/65.jpg)
Studying if quality metrics / bad smells capture
refactoring operations
3 open source systems
11 quality metrics
![Page 66: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/66.jpg)
Studying if quality metrics / bad smells capture
refactoring operations
3 open source systems
11 quality metrics11 bad smells
![Page 67: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/67.jpg)
Studying if quality metrics / bad smells capture
refactoring operations
3 open source systems
11 quality metrics11 bad smells
12,922 refactoring operations manually validated
![Page 68: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/68.jpg)
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)
![Page 69: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/69.jpg)
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)
http://www.sesa.unisa.it/tools/aries.jsp
![Page 70: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/70.jpg)
Moving Forward
![Page 71: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/71.jpg)
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)
![Page 72: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/72.jpg)
F. Palomba“Textual Analysis for Code Smell Detection”
Submitted to the International Conference on Software Engineering (ICSE 2015)
![Page 73: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/73.jpg)
Learning from the past for prioritizing bad code smells
![Page 74: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/74.jpg)
Technical Debt is...“Not quite right code which we
postpone making it right.”
W. Cunningham
Documentation DebtCode Smell
Test debt
Coding Style Violation
Structural DebtArchitectural Debt
Low Internal Quality
Code Complexity
![Page 75: PhD Symposium 2014](https://reader033.vdocuments.us/reader033/viewer/2022060204/559f5ccd1a28ab286b8b4788/html5/thumbnails/75.jpg)
Fabio Palombafpalomba.unisa.itdibt.unimol.it/fpalomba
Research is a work of