Notes on software that explains itself

Clarity is part of the work.

A name, a comment, and an example each help a reader understand a different part of a program. This journal looks at the everyday writing choices that make small pieces of software easier to discuss and maintain.

Read the field guide

Let the name carry the ordinary meaning.

A useful name helps the reader recognise the role of a value in its immediate setting. “Selected item” can be more informative than a vague “data” when that is the actual concept.

Keep neighbouring names distinct. If two values represent an original list and a filtered list, their names should make that relationship apparent without a separate explanation.

Put the surprise in the comment.

A comment is most useful when it explains a reason the code cannot make obvious on its own. Describe the constraint, the intended behaviour, or a non-obvious choice.

Avoid narrating each operation in different words. When a comment and the code say the same thing, a clearer name may serve the reader better.

Give the example a job.

An example should reveal a boundary or a typical use. A short list with one missing entry can explain absence more clearly than a large collection of arbitrary values.

State what the example is intended to show. The reader should not have to guess whether an unusual value is deliberate or accidental.

Concept
A selected item can be absent from the current filtered view without having been removed from the original collection.
Naming
Keep “visible items” separate from “all items” when both concepts are present.
Example
Show a selected item before and after filtering so that the intended relationship can be discussed directly.

Read across the boundary.

A small piece of code lives beside callers, documentation, and the user-visible behaviour it supports. Check whether the same concept keeps the same name across those edges.

When the language changes, explain why. A translation between an interface label and an internal concept should be a deliberate relationship rather than a hidden puzzle.

Can the name stand without a comment?

Read it in the surrounding sentence or operation. Check that its ordinary meaning matches its actual role.

What does the reader need to know why?

Save comments for the reasons and constraints that are easy to lose during a later edit.

Does the example expose the boundary?

A useful example makes a distinction visible. It does not merely demonstrate that some input produces some output.

Give one small piece a clearer voice.

Use the guide to review names, comments, and examples together. Work on a bounded section so the explanation stays connected to its context.

Open the practical guide