International Conference

Characterising the Knowledge about Primitive Variables in Java Code Comments

Mahfouth Alghamdi, Shinpei Hayashi, Takashi Kobayashi, Christoph Treude

In Proceedings of the 18th IEEE/ACM International Conference on Mining Software Repositories (MSR 2021), pp. 460–470, May 2021.

Abstract

Primitive types are fundamental components available in any programming language, which serve as the building blocks of data manipulation. Understanding the role of these types in source code is essential to write software. The most convenient way to express the functionality of these variables in the code is through describing them in comments. Little work has been conducted on how often these variables are documented in code comments and what types of knowledge the comments provide about variables of primitive types. In this paper, we present an approach for detecting primitive variables and their description in comments using lexical matching and semantic matching. We evaluate our approaches by comparing the lexical and semantic matching performance in terms of recall, precision, and F-score, against 600 manually annotated variables from a sample of GitHub projects. The performance of our semantic approach based on F-score was superior compared to lexical matching, 0.986 and 0.942, respectively. We then create a taxonomy of the types of knowledge contained in these comments about variables of primitive types. Our study showed that developers usually documented the variables’ identifiers of a numeric data type with their purpose (69.16%) and concept (72.75%) more than the variables’ identifiers of type String which were less documented with purpose (61.14%) and concept (55.46%). Our findings characterise the current state of the practice of documenting primitive variables and point at areas that are often not well documented, such as the meaning of boolean variables or the purpose of fields and local variables.

Video

BibTeX

@inproceedings{mahfouth-msr2021,
    author = {Mahfouth Alghamdi and Shinpei Hayashi and Takashi Kobayashi and Christoph Treude},
    title = {Characterising the Knowledge about Primitive Variables in {Java} Code Comments},
    booktitle = {Proceedings of the 18th IEEE/ACM International Conference on Mining Software Repositories},
    pages = {460--470},
    doi = {10.1109/MSR52588.2021.00058},
    year = 2021,
}
Type
International Conference
Conference
MSR 2021
Presented
May 19, 2021
Volume / Pages
pp. 460–470
DOI
10.1109/MSR52588.2021.00058