Nothing Special   »   [go: up one dir, main page]

skip to main content
research-article

Understanding metric-based detectable smells in Python software

Published: 01 February 2018 Publication History

Abstract

ContextCode smells are supposed to cause potential comprehension and maintenance problems in software development. Although code smells are studied in many languages, e.g. Java and C#, there is a lack of technique or tool support addressing code smells in Python. ObjectiveDue to the great differences between Python and static languages, the goal of this study is to define and detect code smells in Python programs and to explore the effects of Python smells on software maintainability. MethodIn this paper, we introduced ten code smells and established a metric-based detection method with three different filtering strategies to specify metric thresholds (Experience-Based Strategy, Statistics-Based Strategy, and Tuning Machine Strategy). Then, we performed a comparative study to investigate how three detection strategies perform in detecting Python smells and how these smells affect software maintainability with different detection strategies. This study utilized a corpus of 106 Python projects with most stars on GitHub. ResultsThe results showed that: (1) the metric-based detection approach performs well in detecting Python smells and Tuning Machine Strategy achieves the best accuracy; (2) the three detection strategies discover some different smell occurrences, and Long Parameter List and Long Method are more prevalent than other smells; (3) several kinds of code smells are more significantly related to changes or faults in Python modules. ConclusionThese findings reveal the key features of Python smells and also provide a guideline for the choice of detection strategy in detecting and analyzing Python smells.

References

[1]
M. Tufano, F. Palomba, G. Bavota, M.D. Penta, R. Oliveto, A.D. Lucia, D. Poshyvanyk, An empirical investigation into the nature of test smells, in: Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering (ASE), 2016, pp. 4-15.
[2]
M. Fowler, Refactoring: Improving the Design of Existing Code, Addison-Wesley, Reading MA, 1997.
[3]
M. Tufano, F. Palomba, G. Bavota, R. Oliveto, M. Di Penta, A. De Lucia, D. Poshyvanyk, When and why your code starts to smell bad, in: Proceedings of the 37th International Conference on Software Engineering (ICSE), 2015, pp. 403-414.
[4]
F. Khomh, M. Di Penta, Y.-G. Guhneuc, An exploratory study of the impact of code smells on software change-proneness, in: Proceedings of the 16th Working Conference on Reverse Engineering (WCRE), 2009, pp. 75-84.
[5]
S.M. Olbrich, D. Cruzes, D.I.K. Sjberg, Are all code smells harmful? A study of God Classes and Brain Classes in the evolution of three open source systems, in: Proceedings of the 26th IEEE International Conference on Software Maintenance (ICSM), 2010, pp. 1-10.
[6]
A. Lozano, M. Wermelinger, Assessing the effect of clones on changeability, in: Proceedings of the 24th IEEE International Conference on Software Maintenance (ICSM), 2008, pp. 227-236.
[7]
I.S. Deligiannis, I. Stamelos, L. Angelis, A controlled experiment investigation of an object-oriented design heuristic for maintainability, J. Syst. Softw., 72 (2004) 129-143.
[8]
W. Li, R. Shatnawi, An empirical study of the bad smells and class error probability in the post-release object-oriented system evolution, J. Syst. Softw., 80 (2007) 1120-1128.
[9]
D.I.K. Sjberg, A.F. Yamashita, B.C.D. Anda, Quantifying the effect of code smells on maintenance effort, IEEE Trans. Softw. Eng., 39 (2013) 1144-1156.
[10]
M. Abbes, F. Khomh, Y.-G. Guhneuc, An empirical study of the impact of two antipatterns, blob and spaghetti code, on program comprehension, in: Proceedings of the 15th European Conference on Software Maintenance and Reengineering (CSMR), 2011, pp. 181-190.
[11]
B.D. Bois, S. Demeyer, J. Verelst, Does God class decomposition affect comprehensibility?, in: Proceedings of the IASTED International Conference on Software Engineering, 2006, pp. 346-355.
[12]
M. D'Ambros, A. Bacchelli, M. Lanza, On the impact of design flaws on software defects, in: Proceedings of the 10th International Conference on Quality Software (QSIC), 2010, pp. 23-31.
[13]
P.F. Mihancea, R. Marinescu, Towards the optimization of automatic detection of design flaws in object-oriented software systems, in: Proceedings of the 9th European Conference on Software Maintenance and Reengineering (CSMR), 2005, pp. 92-101.
[14]
W.J. Brown, R.C. Malveau, W.H. Brown, H.W. McCormick, T.J. Mowbray, AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis, John Wiley and Sons, March 1998.
[15]
A.F. Yamashita, L. Moonen, Do developers care about code smells? An exploratory survey, in: Proceedings of the 20th Working Conference on Reverse Engineering (WCRE), 2013, pp. 242-251.
[16]
M.J. Munro, Product metrics for automatic identification of bad smell design problems in Java source-code, in: Proceedings of the 11th IEEE International Symposium on Software Metrics, 2005.
[17]
R. Marinescu, Detection strategies: metrics-based rules for detecting design flaws, in: Proceedings of the 20th IEEE International Conference on Software Maintenance (ICSM), 2004, pp. 350-359.
[18]
A.A. Rao, K.N. Reddy, Detecting bad smells in object oriented design using design change propagation probability matrix, in: Proceedings of the International MultiConference of Engineers and Computer Scientists, 2008, pp. 1001-1007.
[19]
F.A. Fontana, M. Zanoni, A. Marino, M.V. Mantyla, Code smell detection: towards a machine learning-based approach, in: Proceedings of the 29th IEEE International Conference on Software Maintenance (ICSM), 2013, pp. 396-399.
[20]
R. Oliveto, F. Khomh, G. Antoniol, Y.G. Guehueneuc, Numerical signatures of antipatterns: an approach based on b-splines, in: CSMR 2010. Proceedings of the 14th European Conference on Software Maintenance and Reengineering (CSMR), 2010, pp. 248-251.
[21]
F. Khomh, S. Vaucher, Y.-G. Guhneuc, H. Sahraoui, A Bayesian approach for the detection of code and design smells, in: Proceedings of the 9th International Conference on Quality Software (QSIC), 2009, pp. 305-314.
[22]
F. Palomba, G. Bavota, M.D. Penta, R. Oliveto, D. Poshyvanyk, A.D. Lucia, Mining version histories for detecting code smells, IEEE Trans. Softw. Eng., 41 (2015) 462-489.
[23]
F. Palomba, G. Bavota, M.D. Penta, R. Oliveto, A.D. Lucia, D. Poshyvanyk, Detecting bad smells in source code using change history information, in: Proceedings of the IEEE/ACM 28th International Conference on Automated Software Engineering (ASE), 2013, pp. 268-278.
[24]
F. Palomba, G. Bavota, M. Di Penta, R. Oliveto, A. De Lucia, Do they really smell bad? A study on developers perception of bad code smells, in: Proceedings of the 30th IEEE International Conference on Software Maintenance and Evolution (ICSME), 2014, pp. 101-110.
[25]
M.F. Sanner, Python: a programming language for software integration and development, J. Mol. Graph. Model., 17 (1999) 57-61.
[26]
N. Moha, Y.-G. Guhneuc, L. Duchien, A.-F. Le Meur, DECOR: a method for the specification and detection of code and design smells, IEEE Trans. Softw. Eng., 36 (2010) 20-36.
[27]
J.L. Fleiss, Measuring nominal scale agreement among many raters, Psychol. Bull., 76 (1971) 378-382.
[28]
J. Cohen, A coefficient of agreement for nominal scales, Educ. Psychol. Meas., 20 (1960) 37-46.
[29]
R. Marinescu, Measurement and quality in object-oriented design, in: Proceedings of the 21st IEEE International Conference on Software Maintenance (ICSM), 2005, pp. 701-704.
[30]
D.M. Beazley, Python Essential Reference, Addison-Wesley Professional, 2009.
[31]
M. Lutz, Programming Python, O'Reilly Media, 2010.
[32]
L. Gong, M. Pradel, M. Sridharan, K. Sen, DLint: dynamically checking bad coding practices in JavaScript, in: Proceedings of International Symposium on Software Testing and Analysis (ISSTA), 2015.
[33]
A.M. Fard, A. Mesbah, JSNose: detecting JavaScript code smells, in: Proceedings of the IEEE 13th International Working Conference on Source Code Analysis and Manipulation (SCAM), 2013, pp. 116-125.
[34]
A. Holkner, J. Harland, Evaluating the dynamic behavior of Python applications, in: Proceedings of the Thirty-Second Australasian Conference on Computer Science, 91, 2009, pp. 19-28.
[35]
B. kerblom, J. Stendahl, M. Tumlin, T. Wrigstad, Tracing dynamic features in python programs, in: Proceedings of the 11th Working Conference on Mining Software Repositories (MSR), 2014, pp. 292-295.
[36]
L. Chen, B. Xu, T. Zhou, X. Zhou, A constraint based bug checking approach for python, in: Proceedings of the 33rd Annual IEEE International Computer Software and Applications Conference (COMPSAC), 2, 2009, pp. 306-311.
[37]
M. Gorbovitski, Y.A. Liu, S.D. Stoller, T. Rothamel, K.T. Tekle, Alias analysis for optimization of dynamic languages, in: Proceedings of the 6th Dynamic Languages Symposium (DLS), 2010, pp. 27-42.
[38]
N. Tsantalis, A. Chatzigeorgiou, Identification of move method refactoring opportunities, IEEE Trans. Softw. Eng., 35 (2009) 347-367.
[39]
Z. Xu, J. Qian, L. Chen, Z. Chen, B. Xu, Static slicing for Python first-class objects, in: Proceedings of the 13th International Conference on Quality Software (QSIC), 2013, pp. 117-124.
[40]
Z. Chen, L. Chen, Y. Zhou, Z. Xu, W.C. Chu, B. Xu, Dynamic slicing of Python programs, in: Proceedings of the IEEE 38th Annual Computer Software and Applications Conference (COMPSAC), 2014, pp. 219-228.
[41]
W. Kessentini, M. Kessentini, H. Sahraoui, A cooperative parallel search-based software engineering approach for code-smells detection, IEEE Trans. Softw. Eng., 40 (2014) 841-861.
[42]
J.R. Landis, G.G. Koch, The measurement of observer agreement for categorical data, Biometrics (1977) 159-174.
[43]
M. Zhang, N. Baddoo, P. Wernick, T. Hall, Prioritising refactoring using code bad smells, in: Proceedings of the 4th IEEE International Conference on Software Testing, Verification and Validation Workshops (ICSTW), 2011, pp. 458-464.
[44]
K.T. Stolee, S.G. Elbaum, Identification, impact, and refactoring of smells in pipe-like web mashups, IEEE Trans. Softw. Eng., 39 (2013) 1654-1679.
[45]
H. Liu, Q. Liu, Z. Niu, Y. Liu, Dynamic and automatic feedback-based threshold adaptation for code smell detection, IEEE Trans. Softw. Eng., 42 (2015) 544-558.
[46]
T. Hall, M. Zhang, D. Bowes, Some code smells have a significant but small effect on faults, ACM Trans. Softw. Eng. Methodol., 23 (2014) 33.
[47]
J. liwerski, T. Zimmermann, A. Zeller, When do changes induce fixes?, in: Proceedings of the International Workshop on Mining Software Repositories (MSR), vol. 30 (4), 2005, pp. 1-5.
[48]
M. Lanza, R. Marinescu, Object-Oriented Metrics in Practice: Using Software Metrics to Characterize, Evaluate, and Improve the Design of Object-Oriented Systems, Springer, 2006.
[49]
F.A. Fontana, V. Ferme, M. Zanoni, A.F. Yamashita, Automatic metric thresholds derivation for code smell detection, in: Proceedings of the 6th International Workshop on Emerging Trends in Software Metrics, 2015, pp. 44-53.
[50]
S. Coxe, S.G. West, L.S. Aiken, The analysis of count data: a gentle introduction to Poisson regression and its alternatives, J. Personality Assess., 91 (2009) 121-136.
[51]
A. Chatzigeorgiou, A. Manakos, Investigating the evolution of bad smells in object-oriented code, in: Proceedings of the 7th International Conference on the Quality of Information and Communications Technology (QUATIC), 2010, pp. 106-115.
[52]
R. Arcoverde, A. Garcia, E. Figueiredo, Understanding the longevity of code smells: preliminary results of an explanatory survey, in: Proceedings of the 4th International Workshop on Refactoring Tools (IWRT), 2011, pp. 33-36.
[53]
N.E. Fenton, S.L. Pfleeger, Software Metrics - A Rigorous and Practical Approach, PWS Publishing, 1998.
[54]
A. Lozano, M. Wermelinger, B. Nuseibeh, Assessing the impact of bad smells using historical information, in: Proceeding of the 9th international workshop on Principles of software evolution (IWPSE), 2007, pp. 31-34.
[55]
I.M. Bertran, A. Garcia, A. von Staa, J. Garcia, N. Medvidovic, On the impact of aspect-oriented code smells on architecture modularity: an exploratory study, in: Proceedings of the 5th Brazilian Symposium on Software Components, Architectures and Reuse (SBCARS), 2011, pp. 41-50.
[56]
F. Rahman, C. Bird, P. Devanbu, Clones: what is that smell?, Empirical Softw. Eng., 17 (2012) 503-530.
[57]
R. Mo, Y. Cai, R. Kazman, L. Xiao, Hotspot patterns: the formal definition and automatic detection of architecture smells, in: Proceedings of the 12th Working IEEE/IFIP Conference on Software Architecture (WICSA), 2015, pp. 51-60.
[58]
F. Khomh, M. Di Penta, Y.-G. Guhneuc, G. Antoniol, An exploratory study of the impact of antipatterns on class change- and fault-proneness, Empirical Softw. Eng., 17 (2012) 243-275.
[59]
D. Ratiu, S. Ducasse, T. Grba, R. Marinescu, Using history information to improve design flaws detection, in: Proceedings of the 8th European Conference on Software Maintenance and Reengineering (CSMR), 2004, pp. 223-232.
[60]
F. Palomba, A. Panichella, A. De Lucia, R. Oliveto, A. Zaidman, A textual-based technique for smell detection, in: Proceedings of the 24th International Conference on Program Comprehension (ICPC), 2016, pp. 1-10.
[61]
A.F. Yamashita, L. Moonen, Do code smells reflect important maintainability aspects?, in: Proceedings of the 28th IEEE International Conference on Software Maintenance (ICSM), 2012, pp. 306-315.
[62]
A.F. Yamashita, L. Moonen, Exploring the impact of inter-smell relations on software maintainability: an empirical study, in: Proceedings of the 35th International Conference on Software Engineering (ICSE), 2013, pp. 682-691.
[63]
R.J. Grissom, J.J. Kim, Effect Sizes for Research: A Broad Practical Approach, Lawrence Earlbaum Associates, 2005.
[64]
L. Chen, W. Ma, Y. Zhou, L. Xu, Z. Wang, Z. Chen, B. Xu, Empirical analysis of network measures for predicting high severity software faults, Sci. China Inf. Sci., 59 (2016).

Cited By

View all
  • (2024)Copilot-in-the-Loop: Fixing Code Smells in Copilot-Generated Python Code using CopilotProceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering10.1145/3691620.3695290(2230-2234)Online publication date: 27-Oct-2024
  • (2020)The Scent of Deep Learning CodeProceedings of the 17th International Conference on Mining Software Repositories10.1145/3379597.3387479(420-430)Online publication date: 29-Jun-2020
  • (2020)Software smell detection techniquesJournal of Software: Evolution and Process10.1002/smr.232033:3Online publication date: 15-Oct-2020
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image Information and Software Technology
Information and Software Technology  Volume 94, Issue C
February 2018
262 pages

Publisher

Butterworth-Heinemann

United States

Publication History

Published: 01 February 2018

Author Tags

  1. Code smell
  2. Detection strategy
  3. Python
  4. Software maintainability

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 04 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Copilot-in-the-Loop: Fixing Code Smells in Copilot-Generated Python Code using CopilotProceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering10.1145/3691620.3695290(2230-2234)Online publication date: 27-Oct-2024
  • (2020)The Scent of Deep Learning CodeProceedings of the 17th International Conference on Mining Software Repositories10.1145/3379597.3387479(420-430)Online publication date: 29-Jun-2020
  • (2020)Software smell detection techniquesJournal of Software: Evolution and Process10.1002/smr.232033:3Online publication date: 15-Oct-2020
  • (2019)Generating tests to analyse dynamically-typed programsProceedings of the 34th IEEE/ACM International Conference on Automated Software Engineering10.1109/ASE.2019.00146(1226-1229)Online publication date: 10-Nov-2019

View Options

View options

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media