Skip to content

Comments that narrate what the code does ("Loop through the users") ​

Comments and text: one of the ways AI coding agents bloat software, from lessloc's pattern catalog. lessloc catches it as narration.

What makes comments that narrate what the code does a bad practice? ​

The standards that call it a bad practice: Clean Code C3 Redundant Comment and Noise Comments; McConnell, Code Complete §32.4 (a comment that repeats the code is not acceptable in finished code); Ousterhout: Comment Repeats Code.

What does lessloc do about comments that narrate what the code does? ​

lessloc catches it as narration. Comments that give a reason are kept.

  • narration (tier 3): Comments that narrate the code, decorate it or restate a name, closing-brace comments, and log lines that narrate each step.

Examples ​

Caught as narration:

python
def total(xs):
    # Loop through the items and add them up
    return sum(xs)

Written well:

python
def total(xs):
    # Refunds are negative, so the sum is already net
    return sum(xs)

The other patterns in Comments and text:

Released under the Apache-2.0 license. · llms.txt