Are Code Examples on an Online Q&A Forum Reliable?: A Study of API Misuse on Stack Overflow

Are Code Examples on an Online Q&A Forum Reliable?: A Study of API Misuse on Stack Overflow
复制标题

DOI:
10.1145/3180155.3180260
复制
发表时间:
2018-05
期刊:
2018 IEEE/ACM 40th International Conference on Software Engineering (ICSE)
影响因子:
--
通讯作者:
Tianyi Zhang;Ganesha Upadhyaya;Anastasia Reinhardt;Hridesh Rajan;Miryung Kim
Tianyi Zhang;Ganesha Upadhyaya;Anastasia Reinhardt;Hridesh Rajan;Miryung Kim
中科院分区:
其他
文献类型:
--
作者:
Tianyi Zhang;Ganesha Upadhyaya;Anastasia Reinhardt;Hridesh Rajan;Miryung Kim

文献摘要

被引文献

相似文献

程序员经常咨询在线问答论坛,如Stack Overflow,以学习新的API。本文对Stack Overflow上API滥用的流行程度和严重程度进行了实证研究。为了减少手动评估工作,我们设计了ExampleCheck,这是一个API使用挖掘框架,它可以从GitHub上超过38万个Java存储库中提取模式,并随后在Stack Overflow帖子中报告潜在的API使用违规行为。我们使用ExampleCheck分析了217,818个Stack Overflow帖子,发现31%可能存在潜在的API使用违规行为,可能会产生意外行为,例如程序崩溃和资源泄漏。这种API误用是由三个主要原因引起的-缺少控制结构、缺少或不正确的API调用顺序以及不正确的保护条件。即使是被其他程序员接受为正确答案或投票的帖子,在API滥用方面也不一定比其他帖子更可靠。这项研究结果需要一种新的方法来增加堆栈溢出与替代API的使用细节,通常不会显示在策划的例子。
Programmers often consult an online Q&A forum such as Stack Overflow to learn new APIs. This paper presents an empirical study on the prevalence and severity of API misuse on Stack Overflow. To reduce manual assessment effort, we design ExampleCheck, an API usage mining framework that extracts patterns from over 380K Java repositories on GitHub and subsequently reports potential API usage violations in Stack Overflow posts. We analyze 217,818 Stack Overflow posts using ExampleCheck and find that 31% may have potential API usage violations that could produce unexpected behavior such as program crashes and resource leaks. Such API misuse is caused by three main reasons—missing control constructs, missing or incorrect order of API calls, and incorrect guard conditions. Even the posts that are accepted as correct answers or upvoted by other programmers are not necessarily more reliable than other posts in terms of API misuse. This study result calls for a new approach to augment Stack Overflow with alternative API usage details that are not typically shown in curated examples.