Carnegie Mellon University
Browse

Code Readability Testing, an Empirical Study

Download (1.03 MB)
journal contribution
posted on 2013-01-01, 00:00 authored by Todd Sedano

Context: A substantial portion of the cost of software during its life cycle is consumed not in its development, but in its ongoing maintenance. One of the factors that leads to improved code maintainability is its readability. When code is difficult to read, it is difficult for subsequent developers to understand its flow and its side effects, and they are likely to introduce new bugs while trying to fix old ones or while extending the code’s original functionality. But how do software developers know they have written readable code?

Objective: This paper presents a new technique, Code Readability Testing, to determine whether code is readable and evaluates whether the technique increases programmers’ ability to write readable code.

Method: The researcher conducted a field study using 21 software engineering master students and followed the Code Readability Testing with each student in four separate sessions evaluating different “production ready” software. After the observations, a questionnaire evaluated the programmer’s perspective.

Results: By following Code Readability Testing, half of the programmers writing “unreadable” code started writing “readable” code after four sessions. Programmers writing “readable” code also improved their ability to write readable code. The study reveals that the most frequent suggestions for increasing code readability are improving variable names, improving method names, creating new methods in order to reduce code duplication, simplifying if conditions and structures, and simplifying loop conditions. The programmers report that readability testing is worth their time. They observe increases in their ability to write readable code. When programmers experience a reader struggling to understand their code, they become motivated to write readable code.

Conclusion: This paper defines code readability, demonstrates that Code Readability Testing improves programmers’ ability to write readable code, and identifies frequent fixes needed to improve code readability.

History

Date

2013-01-01