Analyzing and Supporting Adaptation of Online Code Examples

05/28/2019
by   Tianyi Zhang, et al.
0

Developers often resort to online Q&A forums such as Stack Overflow (SO) for filling their programming needs. Although code examples on those forums are good starting points, they are often incomplete and inadequate for developers' local program contexts; adaptation of those examples is necessary to integrate them to production code. As a consequence, the process of adapting online code examples is done over and over again, by multiple developers independently. Our work extensively studies these adaptations and variations, serving as the basis for a tool that helps integrate these online code examples in a target context in an interactive manner. We perform a large-scale empirical study about the nature and extent of adaptations and variations of SO snippets. We construct a comprehensive dataset linking SO posts to GitHub counterparts based on clone detection, time stamp analysis, and explicit URL references. We then qualitatively inspect 400 SO examples and their GitHub counterparts and develop a taxonomy of 24 adaptation types. Using this taxonomy, we build an automated adaptation analysis technique on top of GumTree to classify the entire dataset into these types. We build a Chrome extension called ExampleStack that automatically lifts an adaptation-aware template from each SO example and its GitHub counterparts to identify hot spots where most changes happen. A user study with sixteen programmers shows that seeing the commonalities and variations in similar GitHub counterparts increases their confidence about the given SO example, and helps them grasp a more comprehensive view about how to reuse the example differently and avoid common pitfalls.

READ FULL TEXT

page 1

page 7

research
10/03/2019

An Empirical Study of C++ Vulnerabilities in Crowd-Sourced Code Examples

Software developers share programming solutions in Q A sites like Stac...
research
03/25/2023

Combining Contexts from Multiple Sources for Documentation-Specific Code Example Generation

Code example is a crucial part of good documentation. It helps the devel...
research
10/28/2022

I Know What You Are Searching For: Code Snippet Recommendation from Stack Overflow Posts

Stack Overflow has been heavily used by software developers to seek prog...
research
08/25/2023

A Large-Scale Study of IoT Security Weaknesses and Vulnerabilities in the Wild

Internet of Things (IoT) is defined as the connection between places and...
research
02/16/2021

Automatic API Usage Scenario Documentation from Technical Q A Sites

The online technical Q A site Stack Overflow (SO) is popular among dev...
research
02/08/2018

Usage and Attribution of Stack Overflow Code Snippets in GitHub Projects

Stack Overflow (SO) is the largest Q&A website for software developers, ...

Please sign up or login with your details

Forgot password? Click here to reset