Syntax, predicates, idioms — what really affects code complexity?

Program comprehension concerns the ability to understand code written by others. But not all code is the same. We use an experimental platform fashioned as an online game-like environment to measure how quickly and accurately 220 professional programmers can interpret code snippets with similar functionality but different structures; snippets that take longer to understand or produce more errors are considered harder. The results indicate, inter alia, that for loops are significantly harder than if s, that some but not all negations make a predicate harder, and that loops counting down are slightly harder than loops counting up. This demonstrates how the effect of syntactic structures, different ways to express predicates, and the use of known idioms can be measured empirically, and that syntactic structures are not necessarily the most important factor. We also found that the metrics of time to understanding and errors made are not necessarily equivalent. Thus loops counting down took slightly longer, but loops with unusual bounds caused many more errors. By amassing many more empirical results like these it may be possible to derive better code complexity metrics than we have today, and also to better appreciate their limitations.

[1]  R. H. Myers Generalized Linear Models: With Applications in Engineering and the Sciences , 2001 .

[2]  Frederick P. Brooks,et al.  No Silver Bullet: Essence and Accidents of Software Engineering , 1987 .

[3]  M. Shepperd,et al.  A critique of cyclomatic complexity as a software metric , 1988, Softw. Eng. J..

[4]  Joseph Gil,et al.  On the correlation between size and metric validity , 2017, Empirical Software Engineering.

[5]  Kevin McDaid,et al.  Spreadsheet debugging behaviour of expert and novice end-users , 2008, WEUSE '08.

[6]  Silvia Mara Abrahão,et al.  Assessing the Effectiveness of Sequence Diagrams in the Comprehension of Functional Requirements: Results from a Family of Five Experiments , 2013, IEEE Transactions on Software Engineering.

[7]  Edsger W. Dijkstra,et al.  Go To Statement Considered Harmful , 2022, Software Pioneers.

[8]  B. Adelson,et al.  The Role of Domain Expenence in Software Design , 1985, IEEE Transactions on Software Engineering.

[9]  Dror G. Feitelson,et al.  Syntax, predicates, idioms — what really affects code complexity? , 2017, Empirical Software Engineering.

[10]  R. Coe,et al.  It's the Effect Size, Stupid What effect size is and why it is important , 2012 .

[11]  Sabine Sonnentag,et al.  Expertise in Software Design , 2006 .

[12]  Robert L. Goldstone,et al.  What Makes Code Hard to Understand? , 2013, ArXiv.

[13]  Glenford J. Myers,et al.  An extension to the cyclomatic measure of program complexity , 1977, SIGP.

[14]  Lennart E. Nacke,et al.  From game design elements to gamefulness: defining "gamification" , 2011, MindTrek.

[15]  Norman F. Schneidewind,et al.  A Complexity Reliability Model , 2009, 2009 20th International Symposium on Software Reliability Engineering.

[16]  Edsger W. Dijkstra,et al.  Letters to the editor: go to statement considered harmful , 1968, CACM.

[17]  Dror G. Feitelson,et al.  How programmers read regular code: a controlled experiment using eye tracking , 2015, Empirical Software Engineering.

[18]  Gunnar R. Bergersen,et al.  Programming Skill, Knowledge and Working Memory Among Software Developers from an Investment Theory Perspective , 2011 .

[19]  Melvin Klerer Experimental Study of a Two-Dimensional Language vs Fortran for First-Course Programmers , 1984, Int. J. Man Mach. Stud..

[20]  Carlos R. Rivero,et al.  ARCC: assistant for repetitive code comprehension , 2017, ESEC/SIGSOFT FSE.

[21]  Gunnar R. Bergersen,et al.  Programming Skill, Knowledge, and Working Memory Among Professional Software Developers from an Investment Theory Perspective , 2011 .

[22]  R. Nigel Horspool,et al.  Code Hunt: Experience with Coding Contests at Scale , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[23]  S. Sonnentag Expertise in professional software design: a process study. , 1998, The Journal of applied psychology.

[24]  Jodi Asbell-Clarke,et al.  Challenging games help students learn: An empirical study on engagement, flow and immersion in game-based learning , 2016, Comput. Hum. Behav..

[25]  Yann-Gaël Guéhéneuc,et al.  Women and men — Different but equal: On the impact of identifier style on source code reading , 2012, 2012 20th IEEE International Conference on Program Comprehension (ICPC).

[26]  Douglas C. Montgomery,et al.  Generalized Linear Models: With Applications in Engineering and the Sciences: Second Edition , 2012 .

[27]  Kate Ehrlich,et al.  Empirical Studies of Programming Knowledge , 1984, IEEE Transactions on Software Engineering.

[28]  Ruven E. Brooks,et al.  Towards a Theory of the Comprehension of Computer Programs , 1983, Int. J. Man Mach. Stud..

[29]  Chris F. Kemerer,et al.  Cyclomatic Complexity Density and Software Maintenance Productivity , 1991, IEEE Trans. Software Eng..

[30]  Birgit Vogel-Heuser,et al.  Female characteristics and requirements in software engineering in mechanical engineering , 2014, 2014 International Conference on Interactive Collaborative Learning (ICL).

[31]  T. Lumley,et al.  The importance of the normality assumption in large public health data sets. , 2002, Annual review of public health.

[32]  Yingxu Wang,et al.  A new measure of software complexity based on cognitive weights , 2003, Canadian Journal of Electrical and Computer Engineering.

[33]  Bill Curtis,et al.  Third time charm: Stronger prediction of programmer performance by software complexity metrics , 1979, ICSE 1979.

[34]  Juho Hamari,et al.  Defining gamification: a service marketing perspective , 2012, MindTrek.

[35]  Hank Kahney,et al.  What do novice programmers know about recursion , 1983, CHI '83.

[36]  Mawal Ali,et al.  A Comparative Literature Survey of Design Patterns Impact on Software Quality , 2013, 2013 International Conference on Information Science and Applications (ICISA).

[37]  B. L. Welch THE SIGNIFICANCE OF THE DIFFERENCE BETWEEN TWO MEANS WHEN THE POPULATION VARIANCES ARE UNEQUAL , 1938 .

[38]  Amy L. Spawr Drive: the surprising truth about what motivates us, Pink, D.H. (2009). New York, NY (pp. 1–242) , 2012 .

[39]  Stanley Letovsky,et al.  Cognitive processes in program comprehension , 1986, J. Syst. Softw..

[40]  Jana Schumann,et al.  Confounding parameters on program comprehension: a literature survey , 2015, Empirical Software Engineering.

[41]  Barbee T. Mynatt The Effect of Semantic Complexity on the Comprehension of Program Modules , 1984, Int. J. Man Mach. Stud..

[42]  Elaine J. Weyuker,et al.  Evaluating Software Complexity Measures , 2010, IEEE Trans. Software Eng..

[43]  Scott D. Brown,et al.  The power law repealed: The case for an exponential law of practice , 2000, Psychonomic bulletin & review.

[44]  Tore Dybå,et al.  Construction and Validation of an Instrument for Measuring Programming Skill , 2014, IEEE Transactions on Software Engineering.

[45]  Kathleen E. Fite Book Review: Pink, D.H. (2009). Drive: The Surprising Truth about What Motivates Us , 2010 .

[46]  Raymond P. L. Buse,et al.  A metric for software readability , 2008, ISSTA '08.

[47]  James C. Spohrer,et al.  What Do Novice Programmers Know About Recursion , 2013 .

[48]  B. Curtis,et al.  Substantiating programmer variability , 1981, Proceedings of the IEEE.

[49]  Keith Kirkpatrick Coding as sport , 2016, Commun. ACM.

[50]  Dror G. Feitelson,et al.  On the effect of code regularity on comprehension , 2014, ICPC 2014.

[51]  Giovanni Denaro,et al.  An empirical evaluation of fault-proneness models , 2002, ICSE '02.

[52]  Ben Shneiderman,et al.  Syntactic/semantic interactions in programmer behavior: A model and experimental results , 1979, International Journal of Computer & Information Sciences.

[53]  Matthew K Belmonte,et al.  Combining computer game-based behavioural experiments with high-density EEG and infrared gaze tracking. , 2010, Journal of visualized experiments : JoVE.

[54]  Anneliese Amschler Andrews,et al.  Program Comprehension During Software Maintenance and Evolution , 1995, Computer.

[55]  Dror G. Feitelson,et al.  Using Students as Experimental Subjects in Software Engineering Research - A Review and Discussion of the Evidence , 2015, ArXiv.

[56]  Sven Apel,et al.  Measuring and modeling programming experience , 2013, Empirical Software Engineering.

[57]  Vairam Arunachalam,et al.  Cognitive processes in program comprehension: An empirical analysis in the Context of software reengineering , 1996, J. Syst. Softw..

[58]  W. Marsden I and J , 2012 .

[59]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[60]  Sallie M. Henry,et al.  Software Structure Metrics Based on Information Flow , 1981, IEEE Transactions on Software Engineering.

[61]  Anas N. Al-Rabadi,et al.  A comparison of modified reconstructability analysis and Ashenhurst‐Curtis decomposition of Boolean functions , 2004 .

[62]  Allen and Rosenbloom Paul S. Newell,et al.  Mechanisms of Skill Acquisition and the Law of Practice , 1993 .

[63]  Sven Apel,et al.  Exploring Software Measures to Assess Program Comprehension , 2011, 2011 International Symposium on Empirical Software Engineering and Measurement.

[64]  Lutz Prechelt Technical opinion: comparing Java vs. C/C++ efficiency differences to interpersonal differences , 1999, CACM.

[65]  Niclas Ohlsson,et al.  Predicting Fault-Prone Software Modules in Telephone Switches , 1996, IEEE Trans. Software Eng..

[66]  Volker Gruhn,et al.  On Experiments for Measuring Cognitive Weights for Software Control Structures , 2007, 6th IEEE International Conference on Cognitive Informatics.

[67]  Václav Rajlich,et al.  Towards standard for experiments in program comprehension , 1997, Proceedings Fifth International Workshop on Program Comprehension. IWPC'97.

[68]  James R. Larus,et al.  Using Paths to Measure, Explain, and Enhance Program Behavior , 2000, Computer.

[69]  P. Mair,et al.  Extended Rasch Modeling: The eRm Package for the Application of IRT Models in R , 2007 .

[70]  Alexander Serebrenik,et al.  Empirical Analysis of the Relationship between CC and SLOC in a Large Corpus of Java Methods , 2014, 2014 IEEE International Conference on Software Maintenance and Evolution.

[71]  Bill Curtis,et al.  An evaluation of the internal quality of business applications: does size matter? , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[72]  Charles Rich Inspection Methods in Programming: Cliches and Plans , 1987 .

[73]  Alan Agresti,et al.  Categorical Data Analysis , 2003 .

[74]  Taghi M. Khoshgoftaar,et al.  Applications of a relative complexity metric for software project management , 1990, J. Syst. Softw..

[75]  Errol R. Iselin Conditional Statements, Looping Constructs, and Program Comprehension: An Experimental Study , 1988, Int. J. Man Mach. Stud..

[76]  Juergen Rilling,et al.  Identifying comprehension bottlenecks using program slicing and cognitive complexity metrics , 2003, 11th IEEE International Workshop on Program Comprehension, 2003..

[77]  Paul Piwowarski,et al.  A nesting level complexity measure , 1982, SIGP.

[78]  Yijun Yu,et al.  Exploring the Influence of Identifier Names on Code Quality: An Empirical Study , 2010, 2010 14th European Conference on Software Maintenance and Reengineering.

[79]  E. E. Grant,et al.  Exploratory experimental studies comparing online and offline programming performance , 1968, CACM.

[80]  Chris Parnin,et al.  On the Nature of Programmer Expertise , 2017, PPIG.

[81]  Markku Tukiainen,et al.  An eye-tracking methodology for characterizing program comprehension processes , 2006, ETRA.

[82]  Rainer Koschke,et al.  Program complexity metrics and programmer opinions , 2012, 2012 20th IEEE International Conference on Program Comprehension (ICPC).

[83]  Dror G. Feitelson,et al.  Effects of Variable Names on Comprehension: An Empirical Study , 2017, 2017 IEEE/ACM 25th International Conference on Program Comprehension (ICPC).

[84]  Michael W. Godfrey,et al.  What Does Control Flow Really Look Like? Eyeballing the Cyclomatic Complexity Metric , 2012, 2012 IEEE 12th International Working Conference on Source Code Analysis and Manipulation.

[85]  Ahmed E. Hassan,et al.  Beyond Lines of Code: Do We Need More Complexity Metrics? , 2011, Making Software.