Interactive Extraction of Examples from Existing Code

Andrew Head, Elena L. Glassman, Björn Hartmann, Marti A. Hearst

Before you do anything else, try the interactive demo online!

Then check out our CHI 2018 paper, watch the video figure, take a look at the source code, and explore the auxiliary material auxiliary material. In the auxiliary material, you'll find details about the formative study design and outcomes, system implementation, and the examples produced during a pilot usability study.

Abstract: Programmers frequently learn from examples produced and shared by other programmers. However, it can be challenging and time-consuming to produce concise, working code examples. We conducted a formative study where 12 participants made examples based on their own code. This revealed a key hurdle: making meaningful simplifications without introducing errors. Based on this insight, we designed a mixed-initiative tool, CodeScoop, to help programmers extract executable, simplified code from existing code. CodeScoop enables programmers to “scoop” out a relevant subset of code. Techniques include selectively including control structures and recording an execution trace that allows authors to substitute literal values for code and variables. In a controlled study with 19 participants, CodeScoop helped programmers extract executable code examples with the intended behavior more easily than with a standard code editor.