一句话:用 fMRI 研究检验代码复杂度度量能否反映程序理解难度,并揭示文本规模与词汇量的认知影响。
论文关注代码复杂度度量能否预测开发者理解程序的难度。作者对19名被试进行功能磁共振成像(fMRI)实验,让其理解不同复杂度的短代码片段,系统分析四类、共41余种代码复杂度度量与神经、行为和主观指标的关系。结果显示,复杂度度量只能有限地解释程序理解中的认知活动;fMRI进一步揭示,代码的文本规模主要驱动注意,词汇量则加重工作记忆负担。作者认为这为质疑复杂度度量有效性的先前研究提供了神经科学证据,并定位了影响程序理解的关键因素,同时提出后续细粒度实验与度量改进方向。
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.
@inproceedings{PeitekAPBS21,
title = {Program Comprehension and Code Complexity Metrics: An fMRI Study},
author = {Norman Peitek and Sven Apel and Chris Parnin and Andre Brechmann and Janet Siegmund},
booktitle = {ICSE},
year = {2021},
doi = {10.1109/icse43902.2021.00056}
}