MAPO: Mining and Recommending API Usage Patterns

MAPO: Mining and Recommending API Usage Patterns
复制标题

DOI:
10.1007/978-3-642-03013-0_15
复制
发表时间:
2009-07
期刊:
--
影响因子:
--
通讯作者:
Hao Zhong;Tao Xie;Lu Zhang;J. Pei;Hong Mei
Hao Zhong;Tao Xie;Lu Zhang;J. Pei;Hong Mei
中科院分区:
其他
文献类型:
--
作者:
Hao Zhong;Tao Xie;Lu Zhang;J. Pei;Hong Mei

文献摘要

被引文献

相似文献

为了提高软件生产率,在构建新的软件系统时,程序员经常通过调用他们的API中提供的方法来重用现有的库或框架。然而,这些API方法通常很复杂,并且没有很好的文档记录。为了熟悉如何使用这些API方法,程序员通常利用源代码搜索工具来搜索使用感兴趣的API方法的代码片段。然而,返回的代码片段数量往往很大,并且数量巨大的代码片段为程序员找到有用的代码片段设置了障碍。为了帮助程序员克服这一障碍,我们开发了一个API使用挖掘框架及其支持工具Mapo(从开源存储库中挖掘API使用模式),用于自动挖掘API使用模式。挖掘模式描述了在特定的使用场景中,一些API方法经常被一起调用,并且它们的使用遵循一些顺序规则。根据程序员的请求,Mapo进一步推荐挖掘的API使用模式及其相关的代码片段。我们的实验结果表明,使用这些模式,Mapo可以帮助程序员更有效地定位有用的代码片段,而不是两个最先进的代码搜索工具。为了调查Mapo是否可以帮助程序员完成编程任务,我们进一步进行了实证研究。结果表明,与使用两种最先进的代码搜索工具相比,使用Mapo,程序员在面对相对复杂的API使用时生成的代码错误更少。
To improve software productivity, when constructing new software systems, programmers often reuse existing libraries or frameworks by invoking methods provided in their APIs. Those API methods, however, are often complex and not well documented. To get familiar with how those API methods are used, programmers often exploit a source code search tool to search for code snippets that use the API methods of interest. However, the returned code snippets are often large in number, and the huge number of snippets places a barrier for programmers to locate useful ones. In order to help programmers overcome this barrier, we have developed an API usage mining framework and its supporting tool called MAPO (Mining API usage Pattern from Open source repositories) for mining API usage patterns automatically. A mined pattern describes that in a certain usage scenario, some API methods are frequently called together and their usages follow some sequential rules. MAPO further recommends the mined API usage patterns and their associated code snippets upon programmers’ requests. Our experimental results show that with these patterns MAPO helps programmers locate useful code snippets more effectively than two state-of-the-art code search tools. To investigate whether MAPO can assist programmers in programming tasks, we further conducted an empirical study. The results show that using MAPO, programmers produce code with fewer bugs when facing relatively complex API usages, comparing with using the two state-of-the-art code search tools.