Program Comprehension and Code Complexity Metrics: An fMRI Study
Norman Peitek, Sven Apel, Chris Parnin, André Brechmann, Janet Siegmund
摘要
Background: Researchers and practitioners have been using code complexity metrics for decades to predict how developers comprehend a program. While it is plausible and tempting to use code metrics for this purpose, their validity is debated, since they rely on simple code properties and rarely consider particularities of human cognition. Aims: We investigate whether and how code complexity metrics reflect difficulty of program comprehension. Method: We have conducted a functional magnetic resonance imaging (fMRI) study with 19 participants observing program comprehension of short code snippets at varying complexity levels. We dissected four classes of code complexity metrics and their relationship to neuronal, behavioral, and subjective correlates of program comprehension, overall analyzing more than 41 metrics. Results: While our data corroborate that complexity metrics can-to a limited degree-explain programmers' cognition in program comprehension, fMRI allowed us to gain insights into why some code properties are difficult to process. In particular, a code's textual size drives programmers' attention, and vocabulary size burdens programmers' working memory. Conclusion: Our results provide neuro-scientific evidence supporting warnings of prior research questioning the validity of code complexity metrics and pin down factors relevant to program comprehension. Future Work: We outline several follow-up experiments investigating fine-grained effects of code complexity and describe possible refinements to code complexity metrics. PRELUDE Let us begin with a short subjective assessment of code complexity. Consider the following code snippet 1 : 1 public List<Integer> compute(int a, int b, int c)
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 12 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Causal Relationships and Programming Outcomes: A Transcranial Magnetic Stimulation Experiment 引用了 Neurological divide: an fMRI study of prose and code writing
- High Expectations: An Observational Study of Programming and Cannabis Intoxication 引用了 Neurological divide: an fMRI study of prose and code writing
- Convergent Representations of Computer Programs in Human and Artificial Neural Networks 引用了 Neurological divide: an fMRI study of prose and code writing
引用它的顶会 Paper12
- Correlates of programmer efficacy and their link to experience: a combined EEG and eye-tracking studyNorman Peitek, Annabelle Bergum, Maurice Rekrut, Jonas Mucke 等FSE 2022 · 28 次引用
- Convergent Representations of Computer Programs in Human and Artificial Neural NetworksShashank Srikant, Ben Lipkin, Anna A. Ivanova, Evelina Fedorenko 等NeurIPS 2022 · 16 次引用
- Causal Relationships and Programming Outcomes: A Transcranial Magnetic Stimulation ExperimentHammad Ahmad, Madeline Endres, Kaia Newman, Priscila Santiesteban 等ICSE 2024 · 2 次引用
- High Expectations: An Observational Study of Programming and Cannabis IntoxicationWenxin He, Manasvi Parikh, Westley Weimer, Madeline EndresICSE 2024 · 2 次引用
- On the Relationship between Code Verifiability and UnderstandabilityKobi Feldman, Martin Kellogg, Oscar ChaparroFSE 2023 · 2 次引用
它引用的 Paper1
相关 Paper
- Rethinking Code Complexity Through the Lens of Large Language ModelsChen Xie, Xiaodong Gu, Yuling Shi, Beijun ShenICML 2026
- The Role of Working Memory in Program TracingWill Crichton, Maneesh Agrawala, Pat HanrahanCHI 2021 · 13 次引用
- The Mind Is a Powerful Place: How Showing Code Comprehensibility Metrics Influences Code UnderstandingMarvin Wyrich, Andreas Preikschat, Daniel Graziotin, Stefan WagnerICSE 2021 · 24 次引用
- Developers' Visuo-spatial Mental Model and Program ComprehensionAbir Bouraffa, Gian-Luca Fuhrmann, Walid MaalejICSE 2023 · 1 次引用
- Are Humans and LLMs Confused by the Same Code? An Empirical Study on Fixation-Related Potentials and LLM PerplexityYoussef Abdelsalam, Norman Peitek, Anna-Maria Maurer, Mariya Toneva 等ICSE 2026
