Automatic Segmentation of Method Code into Meaningful Blocks to Improve Readability

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 r as well as provides hints for internal documentation placement.

[1]  Susan Horwitz,et al.  Effective, automatic procedure extraction , 2003, 11th IEEE International Workshop on Program Comprehension, 2003..

[2]  Shinji Kusumoto,et al.  A metric-based approach to identifying refactoring opportunities for merging code clones in a Java software system , 2008, J. Softw. Maintenance Res. Pract..

[3]  Zhendong Niu,et al.  Identifying Fragments to be Extracted from Long Methods , 2009, 2009 16th Asia-Pacific Software Engineering Conference.

[4]  Jean Scholtz,et al.  The Roles Beacons Play in Comprehension for Novice and Expert Programmers , 2002, PPIG.

[5]  Emily Hill,et al.  Towards automatically generating summary comments for Java methods , 2010, ASE.

[6]  Marie Nordström,et al.  Beauty and the Beast--Toward a Measurement Framework for Example Program Quality , 2007 .

[7]  Premkumar T. Devanbu,et al.  A simpler model of software readability , 2011, MSR '11.

[8]  Lori L. Pollock,et al.  Automatically detecting and describing high level actions within methods , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[9]  Westley Weimer,et al.  Learning a Metric for Code Readability , 2010, IEEE Transactions on Software Engineering.

[10]  Watts S. Humphrey,et al.  Introduction to the Personal Software Process , 1996 .

[11]  Nuzhat J. Haneef Software documentation and readability: a proposed process improvement , 1998, SOEN.

[12]  Raymond P. L. Buse,et al.  A metric for software readability , 2008, ISSTA '08.

[13]  Kim B. Bruce,et al.  Java: An Eventful Approach , 2005 .

[14]  Ruven E. Brooks,et al.  Towards a Theory of the Comprehension of Computer Programs , 1983, Int. J. Man Mach. Stud..

[15]  K. K. Aggarwal,et al.  An integrated measure of software maintainability , 2002, Annual Reliability and Maintainability Symposium. 2002 Proceedings (Cat. No.02CH37318).

[16]  Stephen R. Schach,et al.  Object-oriented and classical software engineering , 1995 .

[17]  Alexander Chatzigeorgiou,et al.  Identification of Extract Method Refactoring Opportunities , 2009, 2009 13th European Conference on Software Maintenance and Reengineering.

[18]  Phillip A. Relf,et al.  Tool assisted identifier naming for improved software readability: an empirical study , 2005, 2005 International Symposium on Empirical Software Engineering, 2005..

[19]  Michael Marcotty,et al.  Improving computer program readability to aid modification , 1982, CACM.

[20]  Andrian Marcus,et al.  Supporting program comprehension with source code summarization , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[21]  Kwan-Liu Ma,et al.  Stable, flexible, peephole pretty-printing , 2008, Sci. Comput. Program..

[22]  Adele Goldberg,et al.  Programmer as Reader , 1987, IEEE Software.

[23]  Martin P. Robillard,et al.  The Emergent Structure of Development Tasks , 2005, ECOOP.

[24]  Itay Maman,et al.  Micro patterns in Java code , 2005, OOPSLA '05.

[25]  Wiel H. Janssen,et al.  Evaluation studies , 1993, Generic Intelligent Driver Support.

[26]  Herb Sutter,et al.  C++ Coding Standards: 101 Rules, Guidelines, and Best Practices (C++ in Depth Series) , 2004 .

[27]  Herb Sutter,et al.  C++ coding standards , 2004 .