It is generally accepted that variables with a narrow syntactic scope can have short names, whereas variables with a broad scope require more informative longer names. We study how names are given in practice, using a dataset of nearly 640 thousand variable names from Java methods, recently introduced by Aman et al. We extend their original analysis by using a finer division of scopes into ranges. We find that indeed variables with broader scope tend to be slightly longer and to include more words. There is also a progression of changes in name structures, with fewer single-letter names and more compound names as the scope increases. But the biggest differences occur at the low-scope end, not the high-scope end. In addition, we present more evidence that words of 6 letters or more are often abbreviated, but this is not affected by scope. Finally, we also analyze the distribution of popularity of names and of words in names, and show that single letter names are much more varied and common than usually thought, even when the variables have a broad scope.
|Original language||American English|
|Title of host publication||Proceedings - 2023 IEEE/ACM 31st International Conference on Program Comprehension, ICPC 2023|
|Publisher||IEEE Computer Society|
|Number of pages||10|
|State||Published - 2023|
|Event||31st IEEE/ACM International Conference on Program Comprehension, ICPC 2023 - Melbourne, Australia|
Duration: 15 May 2023 → 16 May 2023
|Name||IEEE International Conference on Program Comprehension|
|Conference||31st IEEE/ACM International Conference on Program Comprehension, ICPC 2023|
|Period||15/05/23 → 16/05/23|
Bibliographical noteFunding Information:
This research was supported by the ISRAEL SCIENCE FOUNDATION (grant no. 832/18).
© 2023 IEEE.
- name length
- variable name
- variable scope