| Analyzing Code Comments to Boost Program Comprehension |
/* * You are not expected to understand this. */
/* clear the buffer. */
b.start = b.end = 0;
i = 0; // the location.
clearBuffer(b);
location = 0;
/** Performs buffer operation. ... */
{
/* clear the buffer. */
b.start = b.end = 0;
}
A lot of variability!
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
/* This is
one comment extent. */
// This is still // one comment extent.
Postcondition)
// create some test data
Map<String, String> data = createTestData(testSize);
Precondition)
// Unable to find the specified document.
return Status.ERROR;
// onActivityResult request
static final int REQUEST_CODE = 6384;
| Postcondition (What do) | 75 |
| Precondition (Why do) | 37 |
| Value Desc. (What is) | 15 |
| Instruction (Todo, etc.) | 14 |
| Comment Out | 12 |
| Visual Cue | 11 |
| Directive | 8 |
| Guide | 0 |
| Uncategorized | 9 |
Parent: Parent syntax element.
Left: Previous sibling.
Right: Next sibling.
B: Beginning of Comment
I: Inside Comment
O: Other
| Language | Files | SLOC | Comments |
|---|---|---|---|
| Java | 480K | 63M | 4.0M |
| Python | 161K | 29M | 2.2M |
| Category | Precision | Recall | F |
|---|---|---|---|
| Postcondition | 61% | 89% | 0.72 |
| Precondition | 67% | 53% | 0.59 |
| Comment Out | 60% | 75% | 0.67 |
| Visual Cue | 75% | 67% | 0.71 |
| Value Desc. | 50% | 29% | 0.29 |
| Category | Precision | Recall | F |
|---|---|---|---|
| Postcondition | 63% | 66% | 0.64 |
| Precondition | 38% | 26% | 0.20 |
| Comment Out | 10% | 100% | 0.18 |
| Visual Cue | 0% | 0% | 0.00 |
| Value Desc. | 50% | 11% | 0.11 |
| Java | Python |
|---|---|
Postcondition and Precondition).
Postcondition) are
preserved across different languages (Java and Python).
out.getBuffer().setLength(0); // clear buffer
// Clear the off screen buffer. This is // necessary for some phones. canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), clearPaint);
// clear the input stream buffer
String line = inReader.readLine();
while(line != null) {
line = inReader.readLine();
}
do nothing | 332 |
throw exception | 170 |
set default | 161 |
add list | 154 |
do anything | 146 |
set value | 140 |
use default | 122 |
have value | 119 |
create file | 119 |
create list | 116 |
DeltaRows | Distance in lines from a previous comment. |
DeltaCols | Difference in columns from a previous comment. |
DeltaLeft | Difference in columns between a comment and syntax element. |
LeftSyntax | Syntax element left to the comment. |
RightSyntax | Syntax element right to the comment. |
ParentSyntax | Parent syntax element of the comment. |
LeftSyntax | Syntax element left to the comment. |
RightSyntax | Syntax element right to the comment. |
ParentSyntax | Parent syntax element of the comment. |
HasSymbol | Does the comment text include a symbol? |
PosTagFirst | POS tag of the first word of the comment. |
PosTagAny | Does the comment text include a certain POS tag? |
WordFirst | First word of the comment text. |
WordAny | Does the comment text include a certain word? |
| This page intentionally left blank. |