Learning natural coding conventions

By Miltiadis Allamanis, Earl T. Barr, Charles Sutton. 2014

406 citations recorded by the source corpus.

Every programmer has a characteristic style, ranging from preferences about identifier naming to preferences about object relationships and design patterns. Coding conventions define a consistent syntactic style, fostering readability and hence maintainability. When collaborating, programmers strive to obey a project’s coding conventions. However, one third of reviews of changes contain feedback about coding conventions, indicating that programmers do not always follow them and that project members care deeply about adherence. Unfortunately, programmers are often unaware of coding conventions because inferring them requires a global view, one that aggregates the many local decisions programmers make and identifies emergent consensus on style. We present NATURALIZE, a framework that learns the style of a codebase, and suggests revisions to improve stylistic consistency. NATURALIZE builds on recent work in applying statistical natural language processing to source code. We apply NATURALIZE to suggest natural identifier names and formatting conventions. We present four tools focused on ensuring natural code during development and release management, including code review. NATURALIZE achieves 94 % accuracy in its top suggestions for identifier names. We used NATURALIZE to generate 18 patches for 5 open source projects: 14 were accepted.

Subfields: Computer Science Applications, Information Systems, Software, Natural Language Processing, Code Generation & Program Synthesis

How researchers see this paper

The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.

In Computer Science Applications

  1. Premkumar T. Devanbu
  2. Michael Pradel
  3. Charles Sutton
  4. Koushik Sen
  5. Miltiadis Allamanis
  6. Earl T. Barr
  7. Christian Bird
  8. Alberto Bacchelli

In Information Systems

  1. Miltiadis Allamanis
  2. Charles Sutton
  3. Michael Pradel
  4. Premkumar T. Devanbu
  5. Earl T. Barr
  6. Eran Yahav
  7. Koushik Sen
  8. Vincent J. Hellendoorn

In Software

  1. Charles Sutton
  2. Miltiadis Allamanis
  3. Michael Pradel
  4. Premkumar T. Devanbu
  5. Koushik Sen
  6. Earl T. Barr
  7. Vincent J. Hellendoorn
  8. Rishabh Singh

In Natural Language Processing

  1. Charles Sutton
  2. Miltiadis Allamanis
  3. Premkumar T. Devanbu
  4. Michael Pradel
  5. Eran Yahav
  6. Graham Neubig
  7. Vincent J. Hellendoorn
  8. Uri Alon

In Code Generation & Program Synthesis

  1. Charles Sutton
  2. Miltiadis Allamanis
  3. Premkumar T. Devanbu
  4. Michael Pradel
  5. Vincent J. Hellendoorn
  6. Rishabh Singh
  7. Rafael-Michael Karampatsis
  8. Han Liu

Citations in the corpus