Towards Generating Maintainable and Comprehensible API Code Examples

Seham Alharbi, Dimitris Kolovos, Nicholas Matragkas

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

Abstract

One of the most effective resources for learning application programming interfaces (APIs) is code examples. The shortage of such examples can pose a significant learning obstacle for API users. API users desire simple, understandable, self-contained examples that are easy to reuse in their applications. However, writing and maintaining code examples that meet the preferences of API users can be a tedious and repetitive activity for API developers. To address this issue, we present a new approach that aims to ease the writing and maintenance of code examples for API developers, while also improving learnability and comprehension for API users. The approach automatically synthesises linear and more comprehensible API code examples from less repetitive and more maintainable versions by inlining reusable utility methods. We implement this approach in a prototype for the Java programming language. We also evaluate its usefulness in terms of conciseness on a dataset of 600 API code examples extracted from nine open-source Java libraries. The results are encouraging and show that the proposed approach can reduce code repetition and bring a decrease of up to 37% in the lines of code of the evaluated API code examples.

Original languageEnglish
Title of host publicationProceedings - 2024 IEEE International Conference on Software Analysis, Evolution and Reengineering, SANER 2024
PublisherInstitute of Electrical and Electronics Engineers Inc.
Pages830-834
Number of pages5
ISBN (Electronic)9798350330663
ISBN (Print)9798350330670
DOIs
Publication statusPublished - 16 Jul 2024
Event31st IEEE International Conference on Software Analysis, Evolution and Reengineering, SANER 2024 - Rovaniemi, Finland
Duration: 12 Mar 202415 Mar 2024

Publication series

NameProceedings - 2024 IEEE International Conference on Software Analysis, Evolution and Reengineering, SANER 2024
Name
ISSN (Print)1534-5351
ISSN (Electronic)2640-7574

Conference

Conference31st IEEE International Conference on Software Analysis, Evolution and Reengineering, SANER 2024
Country/TerritoryFinland
CityRovaniemi
Period12/03/2415/03/24

Bibliographical note

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

Keywords

  • APIs
  • code examples
  • software maintainability

Cite this