Interactive Extraction of Examples from Existing Code

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

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.

Venue
CHI 2018
Volume
Proceedings of the 2018 CHI Conference on Human Factors in Computing Systems
DOI
10.1145/3173574.3173659
PDF
https://dl.acm.org/doi/pdf/10.1145/3173574.3173659
Anthology ID
2018.chi.85

Cite

@inproceedings{head-etal-2018-interactive,
    title = {{Interactive Extraction of Examples from Existing Code}},
    author = {Andrew Head and Elena L. Glassman and Björn Hartmann and Marti A. Hearst},
    booktitle = {Proceedings of the 2018 CHI Conference on Human Factors in Computing Systems},
    isbn = {9781450356206},
    year = {2018},
    publisher = {Association for Computing Machinery},
    address = {New York, NY, USA},
    doi = {10.1145/3173574.3173659},
    url = {https://doi.org/10.1145/3173574.3173659},
    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.}
}