Special Issue Paper
Automatic Segmentation of Method Code into Meaningful Blocks: Design and Evaluation
Article first published online: 18 FEB 2013
Copyright © 2013 John Wiley & Sons, Ltd.
Journal of Software: Evolution and Process
Special Issue: A Selection of Distinguished Papers from the 18th Working Conference on Reverse Engineering 2011
Volume 26, Issue 1, pages 27–49, January 2014
How to Cite
Wang, X., Pollock, L. and Vijay-Shanker, K. (2014), Automatic Segmentation of Method Code into Meaningful Blocks: Design and Evaluation. J. Softw. Evol. and Proc., 26: 27–49. doi: 10.1002/smr.1581
- Issue published online: 14 JAN 2014
- Article first published online: 18 FEB 2013
- Manuscript Accepted: 4 DEC 2012
- Manuscript Revised: 30 NOV 2012
- Manuscript Received: 31 MAR 2012
- program understanding;
- software tool;
- automatic formatting
Good programming practice and guidelines suggest that programmers use both vertical and horizontal spacing to visibly delineate between code segments that represent different algorithmic steps or high-level actions. Unfortunately, programmers do not always follow these guidelines. Editors and integrated development environments (IDEs) can easily indent codes based on syntax, but they do not currently support automatic blank line insertion, which presents more significant challenges involving the semantics.
This paper presents and evaluates 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 several studies involving human judgments to evaluate the effectiveness of the automatic blank line insertion algorithm, for different size methods and for different levels of programmer expertise. The results indicate strong positive overall opinion of SEGMENT's effectiveness in comparison with both developer-written blank lines and blank lines inserted by newcomers to the code. The results vary only slightly among short and long methods, and among novice and advanced programmers. 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. Copyright © 2013 John Wiley & Sons, Ltd.