Exploring the Impact of Source Code Linearity on the Programmer's Comprehension of API Code Examples

Seham Alharbi*, Dimitris Kolovos

*Corresponding author for this work

Research output: Chapter in Book/Report/Conference proceedingConference contribution

Abstract

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.

Original languageEnglish
Title of host publicationProceedings - 2024 32nd IEEE/ACM International Conference on Program Comprehension, ICPC 2024
PublisherIEEE Computer Society
Pages236-240
Number of pages5
ISBN (Electronic)9798400705861
DOIs
Publication statusPublished - 13 Jun 2024
Event32nd IEEE/ACM International Conference on Program Comprehension, ICPC 2024 - Lisbon, Portugal
Duration: 15 Apr 202416 Apr 2024

Publication series

NameIEEE International Conference on Program Comprehension
ISSN (Print)2643-7147
ISSN (Electronic)2643-7171

Conference

Conference32nd IEEE/ACM International Conference on Program Comprehension, ICPC 2024
Country/TerritoryPortugal
CityLisbon
Period15/04/2416/04/24

Bibliographical note

Publisher Copyright:
© 2024 ACM. This is an author-produced version of the published paper. Uploaded in accordance with the University’s Research Publications and Open Access policy.

Keywords

  • API code examples
  • API comprehension
  • controlled experiment
  • human factors in software engineering
  • source code linearity

Cite this