Skip to main content
Log in

How and why we end up with complex methods: a multi-language study

  • Published:
Empirical Software Engineering Aims and scope Submit manuscript

Abstract

Over time, software systems tend to increase in complexity and become harder to maintain. While the drawbacks of code complexity are well-known, complex code is present in most real software projects. Here, an important question arises: why, with all the advice out there against it, do we continue to end up with complex methods? Unfortunately, code complexity is typically assessed for a single programming language (often Java), reducing the generality of findings. Thus, assessing how and why complex code evolves in multiple programming languages is fundamental to address this limitation. In this paper, we provide a multi-language empirical study to assess the evolution of complex methods and a survey to understand developers’ perceptions. We analyze 1,000 complex methods (according to cyclomatic complexity) of 50 popular projects written in JavaScript, Python, Java, C++, and C# and we perform a survey with over 70 developers. We find that programming language plays an important role in the study of code complexity. For example, C++ and Python projects have more methods that increase complexity over time, whereas Java and C# present more efforts to reduce it. Moreover, the developers’ perception of complexity is subjective and varies per programming language: many analyzed methods are not considered complex by developers, while others are considered well-written or harmless. Furthermore, developers may deliberately avoid refactoring complex code due to several reasons, including code stability and lack of refactoring priority. In some cases, developers are satisfied with complexity or even want to purposely expose it. Finally, based on our findings, we discuss insights for researchers and practitioners.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Fig. 15
Fig. 16
Fig. 17

Similar content being viewed by others

Notes

  1. GitHub ranking: https://bit.ly/2XHn2PY

  2. TIOBE ranking: https://www.tiobe.com/tiobe-index

  3. Lizard project: http://www.lizard.ws and https://github.com/terryyin/lizard

  4. Popular tool to automate building and releasing in iOS and Android apps: https://fastlane.toolsand https://github.com/fastlane/fastlane

  5. Commit available at: https://bit.ly/2LFeFio

  6. Commit available at: https://bit.ly/2ZiYDTt

  7. https://git-scm.com/docs/git-log#Documentation/git-log.txt

  8. https://www.gmass.co

  9. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/is

References

  • Aniche M, Bavota G, Treude C, Gerosa MA, van Deursen A (2018) Code smells for Model-View-Controller architectures. Empir Softw Eng 23:2121–2147

    Article  Google Scholar 

  • Avelino G, Passos L, Hora A, Valente MT (2016) A novel approach for estimating truck factors. In: 24th International Conference on Program Comprehension (ICPC), pp 1–10

  • Avelino G, Passos L, Hora A, Valente MT (2019) Measuring and analyzing code authorship in 1 + 118 open source projects. Sci Comput Program 176 (1):14–32

    Article  Google Scholar 

  • Ayalew Y, Mguniin K (2013) An assessment of changeability of open source software. Computer and Information Science 6(3):68–79

    Article  Google Scholar 

  • Borges H, Hora A, Valente MT (2016) Understanding the factors that impact the popularity of GitHub repositories. In: International conference on software maintenance and evolution (ICSME), pp 334–344

  • Bray MW, Brune K, Fisher D, Foreman J, Gerken M (1997) C4 software technology reference guide - a prototype

  • Brito A, Valente MT, Xavier L, Hora A (2020) You broke my code: understanding the motivations for breaking changes in apis. Empir Softw Eng 25:1458–1492

    Article  Google Scholar 

  • Chatzigeorgiou A, Manakos A (2010) Investigating the evolution of bad smells in object-oriented code. In: International conference on the quality of information and communications technology. IEEE, pp 106–115

  • Chatzigeorgiou A, Manakos A (2014) Investigating the evolution of code smells in object-oriented systems. Innov Syst Softw Eng 10(1):3–18

    Article  Google Scholar 

  • Chen Z, Chen L, Ma W, Xu B (2016) Detecting code smells in python programs. In: International conference on software analysis, testing and evolution (SATE), pp 18–23

  • Chi-Square - College of Education - NIU (2021) https://www.cedu.niu.edu/~walker/statistics/Chi%20Square%202.pdf

  • Code Climate (2021) https://docs.codeclimate.com/docs/cyclomatic-complexity

  • Cruzes DS, Dyba T (2011) Recommended steps for thematic synthesis in software engineering. In: 2011 International symposium on empirical software engineering and measurement (ESEM), pp 275–284

  • Di Nucci D, Palomba F, Tamburri DA, Serebrenik A, De Lucia A (2018) Detecting code smells using machine learning techniques: Are we there yet?. In: International conference on software analysis, evolution and reengineering (SANER), pp 612–621

  • Dias M, Bacchelli A, Gousios G, Cassou D, Ducasse S (2015) Untangling fine-grained code changes. In: International conference on software analysis, evolution, and reengineering (SANER), pp 341–350

  • Fard AM, Mesbah A (2013) JSNOSE: Detecting JavaScript Code Smells. In: International working conference on source code analysis and manipulation (SCAM), pp 116–125

  • Fischer M, Pinzger M, Gall H (2003) Populating a release history database from version control and bug tracking systems. In: International conference on software maintenance (ICSM), pp 23–32

  • Fontana F A, Braione P, Zanoni M (2012) Automatic detection of bad smells in code: An experimental assessment. J Object Technology 11(2):5–1

    Google Scholar 

  • Fowler M (2018) Refactoring: Improving the design of existing code. Addison-Wesley Professional

  • Grund F, Chowdhury SA, Bradley N, Hall B, Holmes R (2021) CodeShovel: Constructing Method-Level Source Code Histories. In: International conference on software enginnering (ICSE)

  • Herzig K, Just S, Zeller A (2013) It’s not a bug, it’s a feature: How misclassification impacts bug prediction. In: International conference on software engineering (ICSE), pp 392–401

  • Hora A, Anquetil N, Ducasse S, Allier S (2012) Domain specific warnings: Are they any better?. In: 2012 28th IEEE International conference on software maintenance (ICSM), pp 441–450

  • Hora A, Robbes R (2020) Characteristics of method extractions in java: A large scale empirical study. Empir Softw Eng 25:1798–1833

    Article  Google Scholar 

  • Host E W, Ostvold B M (2007) The programmer’s lexicon, volume i: The verbs. In: International working conference on source code analysis and manipulation, pp 193–202

  • IBM Rational Asset Analyzer (2021) https://www.ibm.com/docs/en/raa/6.1?topic=metrics-cyclomatic-complexityhttps://www.ibm.com/docs/en/raa/6.1?topic=metrics-cyclomatic-complexity

  • Jbara A, Matan A, Feitelson DG (2014) High-mcc functions in the linux kernel. Empir Softw Eng 19:1261–1298

    Article  Google Scholar 

  • Johannes D, Khomh F, Antoniol G (2019) A large-scale empirical study of code smells in JavaScript projects. Software Quality 27:1271–1314

    Article  Google Scholar 

  • Kendall MG (1948) Rank correlation methods. Griffin

  • Khomh F, Di Penta M, Gueheneuc Y (2009) An exploratory study of the impact of code smells on software change-proneness. In: Working conference on reverse engineering, pp 75–84

  • Khomh F, Vaucher S, Guéhéneuc Y, Sahraoui H (2009) A bayesian approach for the detection of code and design smells. In: International conference on quality software, pp 305–314

  • Kim S, Whitehead, EJ, Zhang Y (2008) Classifying software changes: Clean or buggy?. IEEE Trans Softw Eng 34(2):181–196

    Article  Google Scholar 

  • Lanza M (2001) The evolution matrix: Recovering software evolution using software visualization techniques. International workshop on principles of software evolution (IWPSE)

  • Lehman MM (1996) Laws of software evolution revisited. In: European workshop on software process technology. Springer, pp 108–124

  • Lehman MM (1980) Programs, life cycles, and laws of software evolution. Proc IEEE 68(9):1060–1076

    Article  Google Scholar 

  • Lehman MM, Ramil JF, Wernick PD, Perry DE, Turski WM (1997) Metrics and laws of software evolution-the nineties view. In: International software metrics symposium. IEEE, pp 20–32

  • Liu H, Gong X, Liao L, Li B (2018) Evaluate how cyclomatic complexity changes in the context of software evolution. In: Annual computer software and applications conference (COMPSAC), vol 02, pp 756–761

  • Maneerat N, Muenchaisri P (2011) Bad-smell prediction from software design model using machine learning techniques. In: International joint conference on computer science and software engineering (JCSSE), pp 331–336

  • Mann HB (1945) Nonparametric tests against trend. Econometrica 13(3):245–259

    Article  MathSciNet  Google Scholar 

  • Martin RC (2009) Clean code: a handbook of agile software craftsmanship. Pearson Education

  • McCabe TJ (1976) A complexity measure. IEEE Trans Softw Eng SE-2(4):308–320

    Article  MathSciNet  Google Scholar 

  • Microsoft Visual Studio (2021) https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-cyclomatic-complexityhttps://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-cyclomatic-complexity

  • Moha N, Gueheneuc Y, Duchien L, Le Meur A (2010) Decor: A method for the specification and detection of code and design smells. IEEE Trans Softw Eng 36(1):20–36

    Article  Google Scholar 

  • Olbrich S, Cruzes DS, Basili V, Zazworka N (2009) The evolution and impact of code smells: A case study of two open source systems. In: International symposium on empirical software engineering and measurement. IEEE, pp 390–400

  • Olbrich SM, Cruzes DS, Sjøberg DIK (2010) Are all code smells harmful? a study of god classes and brain classes in the evolution of three open source systems. In: International conference on software maintenance. IEEE, pp 1–10

  • Palomba F, Bavota G, Di Penta M, Oliveto R, De Lucia A, Poshyvanyk D (2013) Detecting bad smells in source code using change history information. In: International conference on automated software engineering (ASE), pp 268–278

  • Palomba F, Bavota G, Di Penta M, Oliveto R, De Lucia A (2014) Do they really smell bad? a study on developers’ perception of bad code smells. In: International conference on software maintenance and evolution. IEEE, pp 101–110

  • Perforce (2021) https://www.perforce.com/blog/qac/what-cyclomatic-complexity

  • Peters R, Zaidman A (2012) Evaluating the lifespan of code smells using software repository mining. In: European conference on software maintenance and reengineering, pp 411–416

  • Ratzinger J, Sigmund T, Gall HC (2008) On the relation of refactorings and software defect prediction. In: International working conference on mining software repositories, pp 35–38

  • Robles G, Herraiz I, German DM, Izquierdo-Cortazar D (2012) Modification and developer metrics at the function level: Metrics for the study of the evolution of a software project. In: International workshop on emerging trends in software metrics (WETSoM), pp 49–55

  • Saboury A, Musavi P, Khomh F, Antoniol G (2017) An empirical study of code smells in JavaScript projects. In: International conference on software analysis, evolution and reengineering (SANER), pp 294–305

  • Silva D, da Silva JP, Santos G, Terra R, Valente MT (2020) Refdiff 2.0: A multi-language refactoring detection tool. IEEE Trans Softw Eng 1 (1):1–17

    Google Scholar 

  • Silva D, Tsantalis N, Valente MT (2016) Why we refactor? confessions of GitHub contributors. In: International symposium on the foundations of software engineering, pp 858–870

  • Silva D, Valente MT (2017) RefDiff: detecting refactorings in version histories. In: International conference on mining software repositories, pp 269–279

  • Silva H, Valente M T (2018) What’s in a GitHub star? understanding repository starring practices in a social coding platform. J Syst Softw 146:112–129

    Article  Google Scholar 

  • Sjøberg DIK, Yamashita A, Anda BCD, Mockus A, Dybå T (2013) Quantifying the effect of code smells on maintenance effort. IEEE Trans Softw Eng 39(8):1144–1156

    Article  Google Scholar 

  • Skolka P, Staicu C-A, Pradel M (2019) Anything to Hide? Studying Minified and Obfuscated Code in the Web. In: The world wide web conference, pp 1735–1746

  • SonarQube (2021) https://docs.sonarqube.org/latest/user-guide/metric-definitions

  • Spadini D, Aniche M, Bacchelli A (2018) Pydriller: Python framework for mining software repositories. In: Joint meeting on european software engineering conference and symposium on the foundations of software engineering, pp 908–911

  • Stroggylos K, Spinellis D (2007) Refactoring–does it improve software quality?. In: International workshop on software quality (WoSQ’07: ICSE Workshops 2007), pp 10–10

  • Taibi D, Janes A, Lenarduzzi V (2017) How developers perceive smells in source code: A replicated study. Inf Softw Technol 92:223–235

    Article  Google Scholar 

  • Tsantalis N, Mansouri M, Eshkevari LM, Mazinanian D, Dig D (2018) Accurate and efficient refactoring detection in commit history. In: International conference on software engineering, pp 483–494

  • Tufano M, Palomba F, Bavota G, Oliveto R, Di Penta M, De Lucia A, Poshyvanyk D (2015) When and why your code starts to smell bad. In: International conference on software engineering, vol 1. IEEE, pp 403–414

  • Tufano M, Palomba F, Bavota G, Oliveto R, Di Penta M, De Lucia A, Poshyvanyk D (2017) When and why your code starts to smell bad (and whether the smells go away). IEEE Trans Softw Eng 43(11):1063–1088

    Article  Google Scholar 

  • van Emden E, Moonen L (2002) Java quality assurance by detecting code smells. In: Working conference on reverse engineering, 2002. Proceedings., pp 97–106

  • Vavrová N, Zaytsev V (2017) Does Python Smell Like Java? Tool Support for Design Defect Discovery in Python. Computing Research Repository, abs/1703.10882

  • Yamashita A, Moonen L (2012) Do code smells reflect important maintainability aspects?. In: International conference on software maintenance (ICSM), pp 306–315

  • Yamashita A, Moonen L (2013) Exploring the impact of inter-smell relations on software maintainability: An empirical study. In: International conference on software engineering (ICSE), pp 682–691

  • Yamashita A, Moonen L (2013) Do developers care about code smells? an exploratory survey. In: Working conference on reverse engineering (WCRE). IEEE, pp 242–251

  • Yue S, Pilon P, Cavadias G (2002) Power of the mann–kendall and spearman’s rho tests for detecting monotonic trends in hydrological series. J Hydrol 259(1):254–271

    Article  Google Scholar 

  • Zimmermann T, Premraj R, Zeller A (2007) Predicting defects for eclipse. In: International workshop on predictor models in software engineering (PROMISE’07: ICSE Workshops 2007), pp 9–9

Download references

Acknowledgment

This research is supported by CAPES, CNPq, and FAPEMIG.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Andre Hora.

Additional information

Communicated by: Xin Xia

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Lopes, M., Hora, A. How and why we end up with complex methods: a multi-language study. Empir Software Eng 27, 115 (2022). https://doi.org/10.1007/s10664-022-10144-3

Download citation

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1007/s10664-022-10144-3

Keywords

Navigation