Detecting Bad Smells in Source Code using Change History Information
Upcoming SlideShare
Loading in...5
×
 

Detecting Bad Smells in Source Code using Change History Information

on

  • 9,911 views

Code smells represent symptoms of poor implementation choices. Previous studies found that these smells make source code more difficult to maintain, possibly also increasing its fault-proneness. There ...

Code smells represent symptoms of poor implementation choices. Previous studies found that these smells make source code more difficult to maintain, possibly also increasing its fault-proneness. There are several approaches that identify smells based on code analysis techniques. However, we observe that many code smells are intrinsically characterized by how code elements change over time. Thus, relying solely on structural information may not be sufficient to detect all the smells accurately. We propose an approach to detect five different code smells, namely Divergent Change, Shotgun Surgery, Parallel Inheritance, Blob, and Feature Envy, by exploiting change history information mined from versioning systems. We applied approach, coined as HIST (Historical Information for Smell deTection), to eight software projects written in Java, and wherever possible compared with existing state-of-the-art smell detectors based on source code analysis. The results indicate that HIST’s precision ranges between 61% and 80%, and its recall ranges between 61% and 100%. More importantly, the results confirm that HIST is able to identify code smells that cannot be identified through approaches solely based on code analysis.

Statistics

Views

Total Views
9,911
Views on SlideShare
9,627
Embed Views
284

Actions

Likes
12
Downloads
36
Comments
0

15 Embeds 284

http://66.228.45.187 143
http://kentothemes.com 64
http://127.0.0.1 40
http://www.linkedin.com 10
http://localhost 10
http://www.google.com 6
http://alex-3w.blogspot.com 2
http://cea4022.1bestarinet.net 2
http://kee7017.1bestarinet.net 1
http://192.168.0.106 1
http://new.reseaulieu.be 1
https://twitter.com 1
http://bibblio.org 1
http://www.pulse.me 1
http://dea1128.1bestarinet.net 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Detecting Bad Smells in Source Code using Change History Information Detecting Bad Smells in Source Code using Change History Information Presentation Transcript

    • Fabio Palomba DETECTING BAD SMELLS IN SOURCE CODE USING CHANGE HISTORY INFORMATION Universityofsalerno fisciano,27/09/2013 Candidate: Fabio Palomba @fabiopalomba3 ADVISORS: Andrea De Lucia Gabriele Bavota sabato 28 settembre 13
    • TODAY, I’LL SPEAK ABOUT... Bad Code: causes and effects Software Evolution and Code Quality HIST: Historical Information for Smell deTection A Method to Detect Bad Smells using Historical Informations sabato 28 settembre 13
    • SOFTWARE EVOLUTION AND CODE QUALITY PART I sabato 28 settembre 13
    • Cohesion Coupling W. Stevens, G. Myers, and L. Constantine. Structured design. IBM Systems Journal, 13(2):115 - 139, 1974. sabato 28 settembre 13
    • sabato 28 settembre 13
    • Victor R. Basili, Lionel C. Briand, and Walcélio L. Melo.A validation of object- oriented design metrics as quality indicators. IEEETransactions on Software Engineering, 22(10):751 - 761, 1996. L. C. Briand, J.Wüst, J.W. Daly, andV. D. Porter. Exploring the relationship between design measures and software quality in object- oriented systems. Journal of Systems and Software (JSS), 51(3):245 - 273, 2000. DEFECTS sabato 28 settembre 13
    • COMPREHENSIBILITY 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,” in 15th European Conference on Software Maintenance and Reengineering, CSMR 2011. sabato 28 settembre 13
    • Tibor Gyimóthy, Rudolf Ferenc, and István Siket. Empirical validation of object- oriented metrics on open source software for fault prediction. IEEETransactions on Software Engineering (TSE), 31(10):897 - 910, 2005. PRODUCTIVITY sabato 28 settembre 13
    • 2 - 100 MAINTENANCE COSTS ARE GREATER THAN DEVELOPMENT COSTS R.D. Banker, S. M. Datar, C. F. Kemerer, D. Zweig. Software complexity and maintenance costs. Communications of the ACM, v.36 n.11, pages 81 - 94, 1993. sabato 28 settembre 13
    • HIST: HISTORICAL INFORMATION FOR SMELL DETECTION PART II sabato 28 settembre 13
    • An AntiPattern is a literary form that describes a commonly occurring solution to a problem that generates decidedly negative consequences William H. Brown, Raphael C. Malveau, Hays W. McCormick,Thomas J. Mowbray - Antipatterns: Refactoring Software,Architectures and Project in Crisis 22 14 BAD SMELLS: DEFINITION DEVELOPMENT ANTIPATTERNSsabato 28 settembre 13
    • DETECTION VIA STRUCTURAL ANALYSIS “Code smell are structural characteristics of software that may indicate a code or design problem.” F. Fontana et al. - “Automatic detection of bad smells in code:An experimental assessment”, Journal of ObjectTechnology sabato 28 settembre 13
    • DETECTION VIA STRUCTURAL ANALYSIS “Code smell are structural characteristics of software that may indicate a code or design problem.” Many bad smells are intrinsically characterized by how code elements change over time, rather than by structural properties! F. Fontana et al. - “Automatic detection of bad smells in code:An experimental assessment”, Journal of ObjectTechnology sabato 28 settembre 13
    • BLOB Feature envy Divergent change shotgun surgery Parallelinheritance hierarchies sabato 28 settembre 13
    • HIST PROCESS sabato 28 settembre 13
    • HIST PROCESS sabato 28 settembre 13
    • EXTRACTING CHANGE HISTORY Changes at method-level are captured using a code-analyzer developed in the Markos European Project* * http://markosproject.berlios.de sabato 28 settembre 13
    • HIST PROCESS sabato 28 settembre 13
    • HIST PROCESS sabato 28 settembre 13
    • DETECTION ALGORITHMS Divergent change occurs when one class is commonly changed in different ways for different reasons. Classes having at least two sets of methods changing together but independently from methods in the other sets 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 sabato 28 settembre 13
    • DETECTION ALGORITHMS Divergent change occurs when one class is commonly changed in different ways for different reasons. Classes having at least two sets of methods changing together but independently from methods in the other sets 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 sabato 28 settembre 13
    • DETECTION ALGORITHMS Divergent change occurs when one class is commonly changed in different ways for different reasons. Classes having at least two sets of methods changing together but independently from methods in the other sets 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 sabato 28 settembre 13
    • MINING VERSION HISTORIES THROUGH ASSOCIATION RULE DISCOVERY C E D B A Files Changesoccurringinsnapshots S1 S2 S3 S4 S5 S6 S7 S8 Thomas Zimmermann, Peter Weißgerber, Stephan Diehl,Andreas Zeller: MiningVersion Histories to Guide Software Changes. ICSE 2004: 563-572 AnnieT.T.Ying, Gail C. Murphy, RaymondT. Ng, Mark Chu-Carroll: Predicting Source Code Changes by Mining Change History. IEEETrans. Software Eng. 30(9): 574-586 (2004) A C B D A D B D E A C B D E A C sabato 28 settembre 13
    • MINING VERSION HISTORIES THROUGH ASSOCIATION RULE DISCOVERY C E D B A Files Changesoccurringinsnapshots S1 S2 S3 S4 S5 S6 S7 S8 Thomas Zimmermann, Peter Weißgerber, Stephan Diehl,Andreas Zeller: MiningVersion Histories to Guide Software Changes. ICSE 2004: 563-572 AnnieT.T.Ying, Gail C. Murphy, RaymondT. Ng, Mark Chu-Carroll: Predicting Source Code Changes by Mining Change History. IEEETrans. Software Eng. 30(9): 574-586 (2004) A C B D A D B D E A C B D E A C sabato 28 settembre 13
    • Classes containing at least one method changing together with methods contained in more than δ(δ=3) different classes DETECTION ALGORITHMS You have a Shotgun Surgery when every time you make a kind of change, you have to make a lot of little changes to a lot of different classes. 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 sabato 28 settembre 13
    • Pairs of classes for which the addition of a subclass implies the addition of a subclass for the other class You have a Parallel Inheritance Hierarchies when every time you make a subclass of one class, you also have to make a subclass of another. DETECTION ALGORITHMS 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 sabato 28 settembre 13
    • DETECTION ALGORITHMS A Blob is a class implementing several responsibilities, having a large number of attributes, operations and dependencies with data classes. Classes modified (in any way) in more than α% (α =8) commits involving at least another class 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 sabato 28 settembre 13
    • DETECTION ALGORITHMS A Feature Envy occurs when a method is more interested in a class other than the one it is actually in. Methods involved in commits with methods of another class of the system β% (β =70) more than commits with methods of their class 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 sabato 28 settembre 13
    • EMPIRICAL EVALUATION sabato 28 settembre 13
    • CASE STUDY DESIGN RQ1:Which are the performance of HIST in detecting bad smells? RQ2: How does HIST compares to the techniques based on structural analysis? RQ System Metrics ApacheTomcat Apache Ant JEdit 5 API Android ApacheTomcat Apache Ant JEdit 5 API Android Precision Recall F-Measure Precision Recall F-Measure Correctti ∩ Correcttj Correctti Correcttj 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 sabato 28 settembre 13
    • 10 % (20 - 7) 0 % (0 - 0) 7 % (4 - 45) 50 % (52 - 49) 63 % (68 - 60) 76 % (73 - 79) 89 % (80 - 100) 61 % (61 - 61) 68 % (76 - 61) 76 % (71 - 81) RESULTS Bad smell HIST Code analysis technique 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 Divergent Change Shotgun Surgery Parallel Inheritance Blob Feature Envy F-Measure (Precision - Recall) F-Measure (Precision - Recall) sabato 28 settembre 13
    • 48 % 41 % 17 % 39 % 35 % 20 % 40 %43 % 17 % RESULTS 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”, in the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13), 2013 0 % 93 % 100 %0 % 7 % 0 % Bad smell HIST ∩ CA HIST CA CA HIST Divergent Change Shotgun Surgery Parallel Inheritance Blob Feature Envy sabato 28 settembre 13
    • Conclusions & Future work sabato 28 settembre 13
    • CONCLUSION “This paper seems to bring some fresh air into an area that has not seen breakthroughs for some time.” [One of the ASE Reviewers] + PRECISION + F - MEASURE + RECALL + Historical analysis for smell detection - Historical information is needed sabato 28 settembre 13
    • CAN WE DEFINE AN HYBRID APPROACH TO DETECT BAD SMELLS? sabato 28 settembre 13
    • CAN WE USE HIST TO DETECT OTHER BAD SMELLS? Spaghetti Code Long Method Complex Class Refused Bequest Duplicate Code Primitive Obsession Middle Man Data Clump sabato 28 settembre 13
    • Fabio Palomba fabiopalomba13 fabio.palomba.89@gmail.com http://www.linkedin.com/pub/fabio-palomba/4a/542/60 University of Salerno DETECTING BAD SMELLS IN SOURCE CODE USING CHANGE HISTORY INFORMATION Thank you! Questions and/or comments sabato 28 settembre 13