
Developers' Focus on Code Smells Severity
Explore whether developers prioritize severe code smells for refactoring, analyzing tools, detection techniques, prioritization challenges, and severity indicators. Investigate the alignment between severity values and developers' perceptions to improve the refactoring process effectively.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Do Developers Focus on Severe Code Smells? Tsubasa Saika1, Eunjong Choi1, Norihiro Yoshida2, Shusuke Haruna1, Katsuro Inoue1 1Osaka University, Japan 2Nagoya University, Japan 1 Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Code Smell A symptom of poor design that may hinder code comprehension[1] Used to find structures in source code that suggest the possibility of refactoring Examples of Code Smell Name Description Recommended Refactoring Extract Class Blob Class A large and complex class Blob Operation A large and complex method Extract Method [1] M. Fowler. Refactoring:Improving the Design of Existing Code. Addison Wesley 1999. 2 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Code Smell Detection Tool Many code quality analysis tools can automatically detect code smell in source code. Most of them use software quality metrics to identify code smell. E.g.) Detection rule for Blob Class[2] LOC > VERY_HIGH WMC > VERY_HIGH AND Blob Class TCC < LOW Containing more than 2 Blob operation 3 [2] M. Lanza and R. Marinescu. Object-Oriented Metrics in Practice. Springer, 2006. Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Prioritization of Code Smell In large-scale source code, tools detect a large number of code smells. Developers must determine which code smells should be preferentially refactored. 4 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Severity of Code Smell To prioritize code smells, several tools calculate the severity value of each detected instances. The severity value of each code smell is calculated based on the software metrics. 2 3 4 5 severity 1 light heavy Several software metrics are used to identify refactoring opportunities[3]. 5 [3] F. Simon et al. Metrics based refactoring. In Proc of CSMR, 2001 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Research Motivation Several code smell detection tools prioritize code smells based on the severity values. It is still unclear whether the severity indicators are in line with developers perception. If not in line with developers perception, severity based prioritization is inappropriate to suggest refactoring. It is necessary to investigate whether developers focus on code with sever code smell. 6 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Overview of Research We investigated the relationship between the severity of code smells and refactoring. Research Questions(RQ) RQ1 Do developers perform refactoring more frequently on code with more sever code smell? RQ2 Does refactoring decrease the severity of code smell? 7 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Analyzed Dataset This study investigated three Java OSS systems. Also used the dataset of refactoring that was collected by Bavota et al.[6] Statistics data of analyzed systems System Period # Release # Class # Refactoring Xerces-J Oct. 1999 - Nov. 2010 34 19,567 6,052 ArgoUML Oct. 2002 - Dec. 2011 12 43,686 3,423 Apache Ant Jan. 2000 - Dec. 2010 18 22,768 1,493 [6] G. Bavota et al. An Experimental investigation on the Innate Relationship between Quality and Refactoring. Journal of Systems and Software, 2015. 8 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Overview of Investigation source code of each release version 1. Detect Code Smell inFusion Collection of severity values 2. Trace severity values Changes of severity values 3. Categorize whether Code Smell was refactored Dataset of Refactoring Refactored classes/methods with Code Smell Non-Refactored classes/methods with Code Smell 4. Conduct significant tests 9 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Detecting Code Smell We used inFusion*1, a tool that detects code smells based on software metrics. It calculates severity value on a scale from 1 to 10. 1 is the most trivial and 10 is the worst E.g.) Detection of Blob Class inFusion 1. Calculates metrics 2. Identifies code smell3. Calculates severity LOC Identifies Class A as Blob Class Calculates the severity based on metrics values WMC Class A TCC Output source Class A type Blob Class severity 4 10 *1http://www.intooitus.com/products/infusion Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Overview of Investigation source code of each release version 1. Detect Code Smell inFusion Collection of severity values 2. Trace severity values Changes of severity values 3. Categorize whether Code Smell was refactored Dataset of Refactoring Refactored classes/methods with Code Smell Non-Refactored classes/methods with Code Smell 4. Conduct significant tests 11 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Tracing Severity Values Trace severity value of each code smell between consecutive release versions Release Version k Release Version k+1 Class A Class A Class Level Class Level no change Type Blob Class severity 4 Type Blob Class severity 4 0 Method Level Method Level increase +1 method m1() m2() Type Blob Operation Sibling Duplications severity 5 1 method m1() m2() Type Blob Operation - severity 6 0 decrease -1 This study considers class/method without smell as severity 0. 12 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Overview of Investigation source code of each release version 1. Detect Code Smell inFusion Collection of severity values 2. Trace severity values Changes of severity values 3. Categorize whether Code Smell was refactored Dataset of Refactoring Refactored classes/methods with Code Smell Non-Refactored classes/methods with Code Smell 4. Conduct significant tests 13 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Overview of Investigation source code of each release version 1. Detect Code Smell inFusion Collection of severity values 2. Trace severity values Changes of severity values 3. Categorize whether Code Smell was refactored Dataset of Refactoring Refactored classes/methods with Code Smell Non-Refactored classes/methods with Code Smell 4. Conduct significant tests 14 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Significant Test For RQ1 RQ1 Do developers perform refactoring more frequently on code with more sever code smell? whether refactored classes/methods have more severe code smells than non-refactored classes/methods We conducted the Mann-Whitney U test, a nonparametric significance test. Group of Refactored Blob Class Group of Non-Refactored Blob Class release 1 class Class A severity 4 release 1 class Class B severity 4 Compare the severity among the same type of Code Smell 1 Class D 10 1 Class C 2 2 Class A 4 2 Class B 8 15 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Results of U-test for RQ1 only coresponding refactoring instances[1,2] all refactoring instances Type of Code Smell Blob Class Data Class Distorted Hierarchy God Class Refused Parent Bequest Schizophrenic Class Tradition Breaker Blob Operation External Duplication Feature Envy Internal Duplication Sibling Duplication significant difference(p<0.05), n/a not applicable n/a n/a n/a n/a [1] M. Fowler. Refactoring:Improving the Design of Existing Code. Addison Wesley 1999. [2] M. Lanza and R. Marinescu. Object-Oriented Metrics in Practice. Springer, 2006. 16 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Significant Test For RQ2 RQ2 Does refactoring decrease the severity of code smell? whether there are significant differences in the change of the severity value between refactored classes/method and non-refactored classes/method We also conducted the Mann-Whitney U test. Group of Refactored Blob Class Group of Non-Refactored Blob Class change of severity change of severity 4 release class release class Compare the change of the severity among the same type of Code Smell 1 2 Class B 1 2 Class A 0 1 2 Class C -1 1 2 Class D -4 2 3 Class B 1 2 3 Class A -2 17 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Results of U-test for RQ2 all refactoring instances n/a n/a only coresponding refactoring instances n/a n/a Type of Code Smell Blob Class Data Class Distorted Hierarchy God Class Refused Parent Bequest Schizophrenic Class Tradition Breaker Blob Operation External Duplication Feature Envy Internal Duplication Sibling Duplication n/a n/a n/a significant difference(p<0.05), n/a not applicable 18 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Summary of Results Only Blob Class and Blob Operation showed significant differences for both RQ1 and RQ2. Refactoring was performed more frequently on code with more severe code smell. Refactoring significantly decreased the severity. The severity was not a useful indicator for the other types of Code Smell. For Blob Class and Blob Operation, it is useful to preferentially show more severe Code Smell to developers. 19 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University
Summary & Future Work Summary This study investigated the effect of the severity of code smells on refactorings. For Blob Class and Blob Operation, developers perform refactoring more frequently on code with more severe code smell. Future Works Analyze additional software systems 20 Department of Computer Science, Graduate School of Information Science and Technology, Osaka University