A comprehensive model for code readability

Simone Scalabrino, Mario Linares‐Vásquez, Rocco Oliveto, Denys Poshyvanyk

Journal of Software Evolution and Process · 2018 · 104 citations · 45 references

Concepts

TL;DR

Unreadable code hampers comprehension and can introduce bugs, yet current readability models focus only on structural aspects of source code, ignoring its natural‑language content. The study extends prior work by incorporating textual features to enhance code readability models. The authors added two textual features and evaluated models on over 600 manually rated code snippets and on 20 systems totaling 3 million lines of code to examine the correlation with FindBugs warnings. The combined model, integrating all features, achieves significantly higher accuracy and more accurately predicts FindBugs warnings than state‑of‑the‑art models.

Abstract

Abstract Unreadable code could compromise program comprehension, and it could cause the introduction of bugs. Code consists of mostly natural language text, both in identifiers and comments, and it is a particular form of text. Nevertheless, the models proposed to estimate code readability take into account only structural aspects and visual nuances of source code, such as line length and alignment of characters. In this paper, we extend our previous work in which we use textual features to improve code readability models. We introduce 2 new textual features, and we reassess the readability prediction power of readability models on more than 600 code snippets manually evaluated, in terms of readability, by 5K+ people. We also replicate a study by Buse and Weimer on the correlation between readability and FindBugs warnings, evaluating different models on 20 software systems, for a total of 3M lines of code. The results demonstrate that (1) textual features complement other features and (2) a model containing all the features achieves a significantly higher accuracy as compared with all the other state‐of‐the‐art models. Also, readability estimation resulting from a more accurate model, ie, the combined model, is able to predict more accurately FindBugs warnings.

References

45