Exempla gratis (E.G.): code examples for free

Celeste Barnaby, Koushik Sen, Tianyi Zhang, Elena L. Glassman, Satish Chandra

Abstract

Modern software engineering often involves using many existing APIs, both open source and – in industrial coding environments– proprietary. Programmers reference documentation and code search tools to remind themselves of proper common usage patterns of APIs. However, high-quality API usage examples are computationally expensive to curate and maintain, and API usage examples retrieved from company-wide code search can be tedious to review. We present a tool, EG, that mines codebases and shows the common, idiomatic us-age examples for API methods. EG was integrated into Facebook’s internal code search tool for the Hack language and evaluated on open-source GitHub projects written in Python. EG was also compared against code search results and hand-written examples from a popular programming website called ProgramCreek. Compared with these two baselines, examples generated by EG are more succinct and representative with less extraneous statements. In addition, a survey with Facebook developers shows that EG examples are preferred in 97% of cases.
BibTeX
@inproceedings{barnaby2020exempla,
  author = {Celeste Barnaby and Koushik Sen and Tianyi Zhang and Elena L. Glassman and Satish Chandra},
  title = {{Exempla gratis (E.G.): code examples for free}},
  booktitle = {ESEC/SIGSOFT FSE},
  year = {2020},
  doi = {10.1145/3368089.3417052},
}

Loading related content...

Figure