Browse Prior Art Database

Code block highlighter

IP.com Disclosure Number: IPCOM000015101D
Original Publication Date: 2001-Sep-16
Included in the Prior Art Database: 2003-Jun-20
Document File: 3 page(s) / 56K

Publishing Venue

IBM

Abstract

Disclosed is a tool or methodology for highlighting, visualising and navigating code in order to make it easier to read and understand. Users of this tool should thereby find it takes less time both to develop new code but also particularly to interpret and maintain existing code. The Problem When examining a listing of program code on the screen or on a print-out it is often difficult to identify the different logical segments of code. The following piece of Java* code is only a short example; serious applications typically comprise many screens or pages of such work: public boolean contains(Point p)

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 49% of the total text.

Page 1 of 3

Code block highlighter

Disclosed is a tool or methodology for highlighting, visualising and navigating code in order to make it easier to read and understand. Users of this tool should thereby find it takes less time both to develop new code but also particularly to interpret and maintain existing code.

The Problem

     When examining a listing of program code on the screen or on a print-out it is often difficult to identify the different logical segments of code. The following piece of Java* code is only a short example; serious applications typically comprise many screens or pages of such work:

public boolean contains(Point p) {

AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {

Rectangle r = ((AccessibleComponent) ac).getBounds();
return r.contains(p);

} else {

Component c = getCurrentComponent();
if (c != null) {

Rectangle r = c.getBounds();
return r.contains(p);

} else {
return getBounds().contains(p);
}

}

}

     Even though programs are often indented to aid interpretation, it can still be easy to misread which code statements correspond to a particular condition, especially with longer listings.

Code Highlighting

     The invention described here seeks to make code easier to read by employing on screen a method sometimes used by hand on printouts of code. Blocks of code (contained within curly braces in the example above) are highlighted by joining the beginning and end of the block with a vertical line in the margin.

Thus, for example, the listing above could be presented instead in the following

way:

public boolean contains(Point p) {

   AccessibleContext ac = getCurrentAccessibleContext();
if (ac instanceof AccessibleComponent) {
Rectangle r = ((AccessibleComponent) ac).getBounds();
return r.contains(p);

} else {
Component c = getCurrentComponent();
│ ╒ if (c != null) {
│ │ Rectangle r = c.getBounds();

1

Page 2 of 3

│ │ return r.contains(p);
│ ├ } else {
│ │ return getBounds().contains(p);
│ ╘ }

   }
}

     This is a trivial example but where nesting gets deeper and code gets longer the human eye can quickly get lost in a morass of brace characters. Ideally this block marking facility would become a standard feature of the integrated development environments (IDEs) of modern compilers in order to facilitate program comprehension.

     The colour of the vertical bars could be chosen according to a variety of schemes, such as:
i) Code nesting level, as illustrated above.
ii) Type of code block (eg., for loop, while loop, if statement, etc.).

iii) 'Rainbow' or alternating colours for adjacent blocks nested at the same level.

Enabling this option would reduce the chances of confusing neighbouring blocks.

     Two further features may also be used to aid comprehension and navigation of the code:

1. Navigation

     By right-clicking the mouse over a vertical bar a drop-down navigation menu could be presented. Options on this menu could include the following:
i) Go to start of current bl...