Automatic Segmentation of Method Code into Meaningful Blocks to Improve Readability

Author : Wang, Xiaoran; Pollock, Lori; Vijay-Shanker, K.
Booktitle : WCRE 2011 – 18th Working Conference on Reverse Engineering
Date : 20 Oct 2011
Pages : 10
Keyword(s) : Program understanding, Readability, Software tool, Automatic formatting
Document Type : In Conference Proceedings
BibTeX Entry : (show)

Abstract :

With the goal of increasing program readability for easier understanding, coding guidelines often include formatting standards such as indenting loop and conditional branch body statements. Similarly, good programming practice suggests that programmers use blank lines to visibly delineate between code segments that represent different algorithmic steps or high level actions. Unfortunately, programmers do not always follow these guidelines. While editors and IDEs can easily indent code based on syntax, they do not currently support automatic blank line insertion, which presents more significant challenges involving the semantics. This paper presents a heuristic solution to the automatic blank line insertion problem, by leveraging both program structure and naming information to identify “meaningful blocks”, consecutive statements that logically implement a high level action. Our tool, SEGMENT, takes as input a Java method, and outputs a segmented version that separates meaningful blocks by vertical spacing. We report on an evaluation of the effectiveness of SEGMENT based on developers’ opinions. SEGMENT assists in making users obtain an overall picture of a method’s actions and comprehend it quicker as well as provides hints for internal documentation placement.

Paper Link

Presentation Link