Identifier Sanitizer
A protocol for fixing vague, jargon, or LLM-generated identifiers in a codebase.
Methods
Test each name with one question. Can a reader guess what it means without opening the file? If not, rename it. A name should say what it does to what —
poll→poll_responses,send→request_colours,of→from_files.Getters say what they return. A getter for a field named
xisget_x, notx()whenxis vague. A bool getter reads as a question:is_busy,is_one_sided.Fix the field when you fix the getter. If
donebecomesget_lines_coloured, the field becomeslines_colouredtoo. One name for one thing.Rename the comments with the code. Every rename includes checking doc comments, inline comments, and diagrams for the old name. Apply the comment-sanitizer decision rule to each touched doc block while you're there.
Decision rule
Rename if the identifier:
- Comes from implementation details the caller doesn't see ("picture" from Unicode spec, "reading" from a parse state)
- Describes the effect rather than the action ("visible" vs "sanitize")
- Packs two questions into one return with no way to name both ("only" meaning "is it one-sided, and which side?")
- Is a single generic word that could mean anything without its type (
get,take,run,of,have)
Keep if:
- The type already says it (
File::path(),Alignment::spans(),Hunk::id()) - It's a standard language convention (
new,len,is_empty,from,into,default) - It's the domain term (
computefor the diff engine,parsefor a parser)