Shorter identifier names take longer to comprehend
Developers spend the majority of their time reading code, a process in which identifier names play a key role. Although many identifier naming styles exist, they often lack an empirical basis and it is not clear whether short or long identifier names facilitate comprehension. In this paper, we investigate the effect of different identifier naming styles (single letters, abbreviations, and words) on program comprehension. We conducted an experimental study with 72 professional C# developers who had to locate defects in source code snippets. We used a within-subjects design, such that each developer worked with all three versions of identifier naming styles, and we measured the time it took them to find a defect. We found that word identifiers led to a 19% increase in speed to find defects compared to meaningless single letters and abbreviations, but we did not find a difference between letters and abbreviations. The results of our study suggest that code is more difficult to comprehend when it contains only letters and abbreviations as identifier names. Words as identifier names facilitate program comprehension and may help to save costs and improve software quality.
KeywordsIdentifier names Program comprehension Professional C# developers Psychology Defect detection Software quality
This work has been supported by the DFG grant SI 2045/2-1. Janet Siegmund’s work is further funded by the Bavarian State Ministry of Education, Science and the Arts in the framework of the Centre Digitisation.Bavaria (ZD.B).
Compliance with Ethical Standards
This study was performed in accordance with the ethical standards of the Department of Psychology, Heidelberg University, Germany.
Conflict of interests
The authors declare that they have no conflict of interest.
- Anquetil N, Lethbridge T (1998) Assessing the relevance of identifier names in a legacy software system. In: Conf. centre for advanced studies on collaborative research, CASCON ’98. IBM Press, Toronto, pp 1–10Google Scholar
- Binkley D, Davis M, Lawrie D, Morrell C (2009) To CamelCase or under_score. In: Proc. Int’l conf. program comprehension (ICPC), pp 158–167. https://doi.org/10.1109/ICPC.2009.5090039
- Ceccato M, Di Penta M, Falcarin P, Ricca F, Torchiano M, Tonella P (2014) A family of experiments to assess the effectiveness and efficiency of source code obfuscation techniques. Empir Softw Eng 19:1040–1074Google Scholar
- Coltheart M, Rastle K, Perry C, Langdon R, Ziegler J (2001) DRC: a dual route cascaded model of visual word recognition and reading aloud. Psychol Rev 108(1):204–256Google Scholar
- Cowan N (2001) The magical number 4 in short-term memory: a reconsideration of mental storage capacity. Behav Brain Sci 24(1):87–185Google Scholar
- Hofmeister J, Siegmund J, Holt DV (2017) Shorter identifier names take longer to comprehend. In: 2017 IEEE 24th International conference on software analysis, evolution and reengineering (SANER), pp 217–227. https://doi.org/10.1109/SANER.2017.7884623
- Lawrie D, Morrell C, Feild H, Binkley D (2006) What’s in a name? A study of identifiers. In: Proc. Int’l conf. program comprehension (ICPC), pp 3–12. https://doi.org/10.1109/ICPC.2006.51
- Leonhart R (2009) Lehrbuch Statistik Einstieg und Vertiefung, 2nd edn. Hans Huber, Hogrefe AG, BernGoogle Scholar
- Miller GA (1994) The magical number seven, plus or minus two: some limits on our capacity for processing information. Psychol Rev 101(2):343–352Google Scholar
- MSDN (2016) Class naming guidelines [online]. available: https://msdn.microsoft.com/en-us/library/4xhs4564(v=vs.71).aspx
- Posnett D, Hindle A, Devanbu P (2011) A simpler model of software readability, ACM, New YorkGoogle Scholar
- Ratcliff R (1993) Methods for dealing with reaction time outliers. Psychol Bull 114(3):510–532Google Scholar
- Scalabrino S, Linares-Vásquez M, Poshyvanyk D, Oliveto R (2016) Improving code readability models with textual features. In: Proc. Int’l conf. program comprehension (ICPC), pp 1–10. https://doi.org/10.1109/ICPC.2016.7503707
- Sharif B, Maletic JI (2010) An eye tracking study on camelcase and under_score identifier styles. In: Proc. Int’l Conf. program comprehension (ICPC). Proc. Int’l Conf. Program Comprehension (ICPC). IEEE Computer Society, Washington, DC, pp 196–205Google Scholar
- Sneed H (1996) Object-oriented COBOL Recycling. In: Proceedings of the Third working conference on reverse engineering, 1996, pp 169–178. https://doi.org/10.1109/WCRE.1996.558901
- Tichy WF (1998) Should computer scientists experiment more? In: IEEE ComputerGoogle Scholar
- Whelan R (2008) Effective analysis of reaction time data. Psychol Record 58 (3):475Google Scholar