arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2404.02377cs.SE
收藏

探索源代码线性化对程序员理解 API 代码示例的影响

Exploring the Impact of Source Code Linearity on the Programmers Comprehension of API Code Examples

Seham Alharbi, Dimitris Kolovos

AI总结:

本文通过61名Java开发者的受控实验,研究API代码示例的线性度和长度对理解与复用的影响,发现线性代码示例能加快反应时间,但在正确性和主观评分上无显著差异,为API开发者优化示例结构提供了启示。

摘要:

背景:应用程序编程接口(API)代码示例是学习 API 的重要知识资源。然而,很少有用户研究探讨代码示例中源代码的结构特征如何影响其可理解性和可复用性。目标:我们研究了 API 代码示例中源代码的(a)线性度和(b)长度是否会影响用户在正确性和所花费时间方面的表现。我们还收集了主观评分。方法:我们进行了一项在线受控代码理解实验,共有 61 名 Java 开发人员参与。作为案例研究,我们使用了 Joda-Time Java 库中的 API 代码示例。我们让参与者在具有不同长度和线性度的示例变体上执行代码理解和复用任务。发现:参与者在接触线性代码示例时表现出更快的反应时间。然而,在正确性或主观评分方面未观察到实质性差异。启示:我们的发现表明,源代码的线性呈现可能会增强对示例的初步理解和可复用性。这反过来可能为 API 开发人员有效组织其 API 代码示例提供一些见解。然而,我们强调需要进一步研究。

英文摘要:

Context: Application Programming Interface (API) code examples are an essential knowledge resource for learning APIs. However, a few user studies have explored how the structural characteristics of the source code in code examples impact their comprehensibility and reusability. Objectives: We investigated whether the (a) linearity and (b) length of the source code in API code examples affect users performance in terms of correctness and time spent. We also collected subjective ratings. Methods: We conducted an online controlled code comprehension experiment with 61 Java developers. As a case study, we used the API code examples from the Joda-Time Java library. We had participants perform code comprehension and reuse tasks on variants of the example with different lengths and degrees of linearity. Findings: Participants demonstrated faster reaction times when exposed to linear code examples. However, no substantial differences in correctness or subjective ratings were observed. Implications: Our findings suggest that the linear presentation of a source code may enhance initial example understanding and reusability. This, in turn, may provide API developers with some insights into the effective structuring of their API code examples. However, we highlight the need for further investigation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑