TY - GEN
T1 - Towards Generating Maintainable and Comprehensible API Code Examples
AU - Alharbi, Seham
AU - Kolovos, Dimitris
AU - Matragkas, Nicholas
N1 - 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.
PY - 2024/7/16
Y1 - 2024/7/16
N2 - 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.
AB - 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.
KW - APIs
KW - code examples
KW - software maintainability
UR - http://www.scopus.com/inward/record.url?scp=85199782262&partnerID=8YFLogxK
U2 - 10.1109/SANER60148.2024.00090
DO - 10.1109/SANER60148.2024.00090
M3 - Conference contribution
AN - SCOPUS:85199782262
SN - 9798350330670
T3 - Proceedings - 2024 IEEE International Conference on Software Analysis, Evolution and Reengineering, SANER 2024
SP - 830
EP - 834
BT - Proceedings - 2024 IEEE International Conference on Software Analysis, Evolution and Reengineering, SANER 2024
PB - Institute of Electrical and Electronics Engineers Inc.
T2 - 31st IEEE International Conference on Software Analysis, Evolution and Reengineering, SANER 2024
Y2 - 12 March 2024 through 15 March 2024
ER -