API usage templates via Structural Generalization

May Mahmoud,Robert J. Walker,Jörg Denzinger
DOI: https://doi.org/10.1016/j.jss.2024.111974
IF: 3.5
2024-01-26
Journal of Systems and Software
Abstract:APIs matter in software development, but determining how to use them can be challenging. Developers often refer to a small set of API usage examples, analyzing the information there to understand and adapt them to their own context. Generalization over many examples may aid in understanding commonalities and differences, reducing information overload while including greater variety. We propose ASGard, a novel approach that generates API usage templates from examples. Approximating the formal problem of E-generalization, ASGard generalizes all syntactic and some semantic information within the examples to arrive at pseudocode representations that retain the commonality of the usage examples but abstract the varying aspects. We evaluate the templates from our approach and the patterns generated from PAM and MUDetect (two existing tools for API data mining), using a total of 1,954 API usage examples across 59 different APIs. We measure the quality of the resulting templates: ASGard's templates have superior completeness and compression. We perform a user study on ASGard with 12 participants to compare the use of these templates in solving programming tasks, compared to MUDetect. We find that participants solved the programming tasks in significantly less time with ASGard. Participants expressed a general preference for using ASGard templates.
computer science, theory & methods, software engineering
What problem does this paper attempt to address?