Post Date
Nov 21 2024

Feature-driven API Usage-based Code Example Recommendation for Opportunistic Reuse

Year
2022
Supervisor:
. Dr. Shafay Shamail
Students:
Shamsa Abid
MS/PhD
PhD
Reference / Filters
Computer Science

Abstract:

Software reuse is a common practice in the development and maintenance of a modern software system. Software developers need to search for reusable code that would assist them in implementing a given feature or development task. Often, the timely discovery of a critical piece of information can have a dramatic impact on productivity. Current code search systems focus on providing code against a specific user query and repeated searches need to be performed until the code for the desired feature or set of features is found. The problem of repeated code searches needs to be addressed and a solution is desired for helping developers to get the code for related features, thus enabling opportunistic reuse for increased developer productivity.

We propose FACER (Feature-driven API usage-based Code Examples Recommender), a recommendation system that provides developers with method recommendations having functionality relevant to their feature or development task. The main idea behind FACER is to provide code recommendations against a feature query based on patterns of frequently co-occurring API usage-based Method Clone Classes. Such patterns are called Method Clone Structures (MCS). The heuristic behind Method Clone Classes is that methods with similar uses of APIs are semantically related because they do similar things and are identified as members of a clone class. FACER generates related method recommendations in two stages. In the first stage, the developer provides a feature query (expressed as a comment) to get a set of methods that implement the feature. In the second stage, upon selection of one of these methods by the developer, a subsequent recommendation provides related methods for opportunistic reuse. Our experimental results show that, on average, FACER's recommendations are 80% precise and that developers find the idea of related method recommendations useful. We also propose a novel ContextAware Feature-driven API usage-based Code Examples Recommender (CA-FACER) that leverages a developer's development context to recommend related code snippets. We consider the methods having API usages in a developer's active project as part of the development context and demonstrate how context-awareness based on API usages can improve the quality of recommendations for Java Android code. From our experimental evaluation on 120 Java Android projects from GitHub, we observe a 46% improvement of precision using our proposed context-aware approach over our baseline FACER. CA-FACER recommends related code examples with an average precision (P@5) of 94% and 83% and a success rate of 90% and 95% for initial and evolved development stages, respectively.

Publications:

S. Abid, S. Shamail, H. A. Basit, and S. Nadi, “FACER: An API usage-based code-example recommender for opportunistic reuse,” Empirical Software Engineering, vol. 26, no. 6, pp. 1-58, Aug 2021.

M. Kamal, A. Abaid, S. Abid, and S. Shamail, “FACER-AS: An API Usage-based Code Recommendation Tool for Android Studio,” proceedings in 2021 IEEE International Conference on Software Maintenance and Evolution (ICSME), IEEE, 2021

S. Abid, “Recommending related functions from API usage-based function clone structures,” Proceedings of the 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, pp. 1193–1195, 2019.

S. Abid, S. Javed, M. Naseem, S. Shahid, H. A. Basit, and Y. Higo, “CodeEase: Harnessing Method Clone Structures for Reuse,” in 2017 IEEE 11th International Workshop on Software Clones (IWSC), pp. 1–7, IEEE, 2017.

S. Abid and H. A. Basit, “Towards a structural clone based recommender system,” in 2016 IEEE 23rd International Conference on Software Analysis, Evolution, and Reengineering (SANER), vol. 3, pp. 51–52, IEEE, 2016.