Date of Original Version

2013

Type

Technical Report

Abstract or Description

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.

Comments

TR # CMU-SV-13-002

Share

COinS
 
 

To view the content in your browser, please download Adobe Reader or, alternately,
you may Download the file to your hard drive.

NOTE: The latest versions of Adobe Reader do not support viewing PDF files within Firefox on Mac OS and if you are using a modern (Intel) Mac, there is no official plugin for viewing PDF files within the browser window.