Type-Directed Code Reuse using Integer Linear Programming

In many common scenarios, programmers need to implement functionality that is already provided by some third party library. This paper presents a tool called Hunter that facilitates code reuse by finding relevant methods in large code bases and automatically synthesizing any necessary wrapper code. The key technical idea underlying our approach is to use types to both improve search results and guide synthesis. Specifically, our method computes similarity metrics between types and uses this information to solve an integer linear programming (ILP) problem in which the objective is to minimize the cost of synthesis. We have implemented Hunter as an Eclipse plug-in and evaluate it by (a) comparing it against S6, a state-of-the-art code reuse tool, and (b) performing a user study. Our evaluation shows that Hunter compares favorably with S6 and significantly increases programmer productivity.

[1]  Jian Pei,et al.  MAPO: Mining and Recommending API Usage Patterns , 2009, ECOOP.

[2]  Eran Yahav,et al.  Code completion with statistical language models , 2014, PLDI.

[3]  Gail C. Murphy,et al.  Using structural context to recommend source code examples , 2005, Proceedings. 27th International Conference on Software Engineering, 2005. ICSE 2005..

[4]  Colin Atkinson,et al.  Code Conjurer: Pulling Reusable Software out of Thin Air , 2008, IEEE Software.

[5]  Kathryn T. Stolee,et al.  Solving the Search for Source Code , 2014, ACM Trans. Softw. Eng. Methodol..

[6]  Koushik Sen,et al.  CodeHint: dynamic and interactive synthesis of code snippets , 2014, ICSE.

[7]  Sumit Gulwani,et al.  Synthesis of loop-free programs , 2011, PLDI '11.

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

[9]  Koushik Sen,et al.  SNIFF: A Search Engine for Java Using Free-Form Queries , 2009, FASE.

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

[11]  Jeannette M. Wing,et al.  Signature matching: a tool for using software libraries , 1995, TSEM.

[12]  Rajeev Motwani,et al.  The PageRank Citation Ranking : Bringing Order to the Web , 1999, WWW 1999.

[13]  William B. Frakes,et al.  An Empirical Study of Representation Methods for Reusable Software Components , 1994, IEEE Trans. Software Eng..

[14]  Sumit Gulwani,et al.  Oracle-guided component-based program synthesis , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[15]  Gerhard Fischer,et al.  Supporting reuse by delivering task-relevant and personalized information , 2002, ICSE '02.

[16]  Collin McMillan,et al.  Portfolio: finding relevant functions and their usage , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[17]  Ruzica Piskac,et al.  Complete completion using types and weights , 2013, PLDI.

[18]  Sumit Gulwani,et al.  Synthesizing geometry constructions , 2011, PLDI '11.

[19]  R. Plackett,et al.  Introduction to Statistical Analysis. , 1952 .

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

[21]  Sushil Krishna Bajracharya,et al.  Sourcerer: An infrastructure for large-scale collection and analysis of open-source code , 2014, Sci. Comput. Program..

[22]  Jeannette M. Wing,et al.  Specification matching of software components , 1997 .

[23]  Ruzica Piskac,et al.  Complete completion using types and weights , 2013, PLDI.

[24]  Collin McMillan,et al.  A search engine for finding highly relevant applications , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[25]  Sushil Krishna Bajracharya,et al.  Applying test-driven code search to the reuse of auxiliary functionality , 2009, SAC '09.

[26]  Gail E. Kaiser,et al.  An Information Retrieval Approach For Automatically Constructing Software Libraries , 1991, IEEE Trans. Software Eng..

[27]  Daniel Le Berre,et al.  The Sat4j library, release 2.2 , 2010, J. Satisf. Boolean Model. Comput..

[28]  André van der Hoek,et al.  CodeExchange: Supporting Reformulation of Internet-Scale Code Queries in Context (T) , 2015, 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE).

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