关于格式元素对代码可读性影响的系统文献综述
A Systematic Literature Review on the Impact of Formatting Elements on Code Legibility
AI总结:
本文通过系统文献综述识别并分类了实证研究中考察的代码格式元素及其层级,揭示了现有证据不足且存在矛盾结果,强调需进一步研究格式元素对代码可读性的影响。
摘要:
背景:软件程序可以用不同但在功能上等价的方式编写。尽管已有研究比较了特定格式元素,以找出哪些替代方案会影响代码可读性,但从整体上把握什么使代码更易读或更难读仍然具有挑战性。目标:我们旨在找出实证研究中已经考察过哪些格式元素,以及对于人类受试者而言,哪些替代方案被发现更易读。方法:我们开展了一项系统文献综述,识别出15篇包含以人为中心研究的论文,这些研究直接比较了不同的格式元素替代方案。我们使用卡片分类法对这些格式元素进行了分析和组织。结果:我们识别出13种格式元素(例如缩进)和33个格式元素层级(例如两空格缩进),它们涉及格式风格、间距、块定界符、长代码行或复杂代码行以及词边界风格。虽然一些层级在代码可读性方面被发现在统计上优于其他等价层级,例如在代码块中适当使用缩进,但另一些层级则没有,例如格式布局。对于标识符风格,我们发现了不一致的结果:一项研究发现支持驼峰命名法的显著差异,而另一项研究则发现了支持蛇形命名法的正向结果。结论:所识别论文的数量(其中一些已经过时),以及大量零结果和相互矛盾的结果,强调了该领域工作的相对缺乏,并凸显了开展更多研究的重要性。在制定指南和自动化辅助工具以帮助开发者提高代码可读性之前,关于格式元素如何影响代码可读性,仍有许多问题有待理解。
英文摘要:
Context: Software programs can be written in different but functionally equivalent ways. Even though previous research has compared specific formatting elements to find out which alternatives affect code legibility, seeing the bigger picture of what makes code more or less legible is challenging. Goal: We aim to find which formatting elements have been investigated in empirical studies and which alternatives were found to be more legible for human subjects. Method: We conducted a systematic literature review and identified 15 papers containing human-centric studies that directly compared alternative formatting elements. We analyzed and organized these formatting elements using a card-sorting method. Results: We identified 13 formatting elements (e.g., indentation) and 33 levels of formatting elements (e.g., two-space indentation), which are about formatting styles, spacing, block delimiters, long or complex code lines, and word boundary styles. While some levels were found to be statistically better than other equivalent ones in terms of code legibility, e.g., appropriate use of indentation with blocks, others were not, e.g., formatting layout. For identifier style, we found divergent results, where one study found a significant difference in favor of camel case, while another study found a positive result in favor of snake case. Conclusion: The number of identified papers, some of which are outdated, and the many null and contradictory results emphasize the relative lack of work in this area and underline the importance of more research. There is much to be understood about how formatting elements influence code legibility before the creation of guidelines and automated aids to help developers make their code more legible.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。