XSnippet: mining For sample code

  • Authors:
  • Naiyana Sahavechaphan;Kajal Claypool

  • Affiliations:
  • National Electronics and Computer Technology Center, Thailand;Oracle Corporation, Nashua, NH

  • Venue:
  • Proceedings of the 21st annual ACM SIGPLAN conference on Object-oriented programming systems, languages, and applications
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

It is common practice for software developers to use examples to guide development efforts. This largely unwritten, yet standard, practice of "develop by example" is often supported by examples bundled with library or framework packages, provided in textbooks, and made available for download on both official and unofficial web sites. However, the vast number of examples that are embedded in the billions of lines of already developed library and framework code are largely untapped. We have developed XSnippet, a context-sensitive code assistant framework that allows developers to query a sample repository for code snippets that are relevant to the programming task at hand. In particular, our work makes three primary contributions. First, a range of queries is provided to allow developers to switch between a context-independent retrieval of code snippets to various degrees of context-sensitive retrieval for object instantiation queries. Second, a novel graph-based code mining algorithm is provided to support the range of queries and enable mining within and across method boundaries. Third, an innovative context-sensitive ranking heuristic is provided that has been experimentally proven to provide better ranking for best-fit code snippets than context-independent heuristics such as shortest path and frequency. Our experimental evaluation has shown that XSnippet has significant potential to assist developers, and provides better coverage of tasks and better rankings for best-fit snippets than other code assistant systems.