Prompt
Choose clear, self-explanatory names that prioritize readability over brevity. Avoid abbreviations, obscure identifiers, and names that require domain knowledge to understand. Names should be immediately comprehensible to newcomers and future maintainers.
Key principles:
- Expand abbreviations to full words (e.g.,
toNetworkOrderHex()instead oftoNEHex()) - Use semantically meaningful names that describe purpose (e.g.,
kjExceptionToJs()instead ofmakeInternalError()) - Avoid double negatives in boolean names (e.g.,
allowNonObjectsinstead ofignoreNonObjects) - Add comments for unavoidably obscure identifiers like
$classthat use special syntax - Choose familiar terminology over internal jargon (e.g.,
typescriptErasableSyntaxover custom terms)
Example:
// Poor: Abbreviation unclear to newcomers
kj::String toNEHex() const;
// Better: Full descriptive name
kj::String toNetworkOrderHex() const;
// Poor: Obscure identifier without context
auto actorClass = options.$class->getChannel(ioCtx);
// Better: Add explanatory comment
// $class uses $ prefix to avoid keyword conflicts in JSG API
auto actorClass = options.$class->getChannel(ioCtx);
This approach reduces cognitive load, improves code maintainability, and helps onboard new team members more effectively.