SnipMatch: using source code context to enhance snippet retrieval and parameterization

Programmers routinely use source code snippets to increase their productivity. However, locating and adapting code snippets to the current context still takes time: for example, variables must be renamed, and dependencies included. We believe that when programmers decide to invest time in creating a new code snippet from scratch, they would also be willing to spend additional effort to make that code snippet configurable and easy to integrate. To explore this insight, we built SnipMatch, a plug-in for the Eclipse IDE. SnipMatch introduces a simple markup that allows snippet authors to specify search patterns and integration instructions. SnipMatch leverages this information, in conjunction with current code context, to improve snippet search and parameterization. For example, when a search query includes local variables, SnipMatch suggests compatible snippets, and automatically adapts them by substituting in these variables. In the lab, we observed that participants integrated snippets faster when using SnipMatch than when using standard Eclipse. Findings from a public deployment to 93 programmers suggest that SnipMatch has become integrated into the work practices of real users.

[1]  Marti A. Hearst Search User Interfaces , 2009 .

[2]  Lena Mamykina,et al.  Design lessons from the fastest q&a site in the west , 2011, CHI.

[3]  Philip J. Guo,et al.  Writing Code to Prototype, Ideate, and Discover , 2009, IEEE Software.

[4]  Eser Kandogan,et al.  Koala: capture, share, automate, personalize business processes on the web , 2007, CHI.

[5]  Sushil Krishna Bajracharya,et al.  Sourcerer: a search engine for open source code supporting structure-based search , 2006, OOPSLA '06.

[6]  Philip J. Guo,et al.  Opportunistic Programming: Writing Code to Prototype, Ideate, and Discover end-us e r soft war e e ngine e ring , 2009 .

[7]  Rastislav Bodík,et al.  Jungloid mining: helping to navigate the API jungle , 2005, PLDI '05.

[8]  Mira Dontcheva,et al.  Zoetrope: interacting with the ephemeral web , 2008, UIST '08.

[9]  Scott R. Klemmer,et al.  Example-centric programming: integrating web search into the development environment , 2010, CHI.

[10]  Flaviu Ghitulescu,et al.  Google Code Search , 2006 .

[11]  Philip J. Guo,et al.  Two studies of opportunistic programming: interleaving web foraging, learning, and writing code , 2009, CHI.

[12]  Michael S. Bernstein,et al.  Inky: a sloppy command line for the web with rich visual feedback , 2008, UIST '08.

[13]  Kajal T. Claypool,et al.  XSnippet: mining For sample code , 2006, OOPSLA '06.

[14]  Steven P. Reiss,et al.  Semantics-based code search , 2009, 2009 IEEE 31st International Conference on Software Engineering.

[15]  Rob Miller,et al.  Translating keyword commands into executable code , 2006, UIST.

[16]  James Fogarty,et al.  Assieme: finding and leveraging implicit references in a web search interface for programmers , 2007, UIST '07.

[17]  Scott R. Klemmer,et al.  Iterative design and evaluation of an event architecture for pen-and-paper interfaces , 2008, UIST '08.

[18]  Peter Morville,et al.  Search Patterns - Design for Discovery , 2010 .

[19]  Miryung Kim,et al.  An ethnographic study of copy and paste programming practices in OOPL , 2004, Proceedings. 2004 International Symposium on Empirical Software Engineering, 2004. ISESE '04..

[20]  Scott R. Klemmer,et al.  What would other programmers do: suggesting solutions to error messages , 2010, CHI.

[21]  Brad A. Myers,et al.  Mica: A Web-Search Tool for Finding API Components and Examples , 2006, Visual Languages and Human-Centric Computing (VL/HCC'06).

[22]  Jian Pei,et al.  MAPO: mining API usages from open source repositories , 2006, MSR '06.

[23]  Joel Brandt,et al.  Codelets: linking interactive documentation and example code in the editor , 2012, CHI.

[24]  Tao Xie,et al.  Parseweb: a programmer assistant for reusing open source code on the web , 2007, ASE.

[25]  R. Holmes,et al.  Using structural context to recommend source code examples , 2005, Proceedings. 27th International Conference on Software Engineering, 2005. ICSE 2005..

[26]  Jaime Teevan,et al.  Visual snippets: summarizing web pages for search and revisitation , 2009, CHI.

[27]  David Salesin,et al.  Relations, cards, and search templates: user-guided web data integration and layout , 2007, UIST.

[28]  Mira Dontcheva,et al.  Exploring websites through contextual facets , 2009, CHI.

[29]  Karen Spärck Jones A statistical interpretation of term specificity and its application in retrieval , 2021, J. Documentation.

[30]  Susan T. Dumais,et al.  The vocabulary problem in human-system communication , 1987, CACM.

[31]  Wayne D. Gray,et al.  Milliseconds Matter: an Introduction to Microstrategies and to Their Use in Describing and Predicting Interactive Behavior Milliseconds Matter: an Introduction to Microstrategies and to Their Use in Describing and Predicting Interactive Behavior , 2022 .

[32]  Rob Miller,et al.  Keyword programming in Java , 2008, Automated Software Engineering.