Prompt
Use clear, self-documenting names for variables, methods, and classes that express intent without exposing unnecessary implementation details.
For methods and variables:
- Avoid abbreviations unless universally understood (use
connectioninstead ofconn,source_locationinstead ofline) - Follow natural language patterns with adjectives before nouns (use
allowed_redirect_hostsinstead ofredirect_hosts_allowed) - Remove implementation details from public API names (use
compute_checksuminstead ofcompute_checksum_in_chunks)
For error classes:
- Follow the “what? kind?” pattern (e.g.,
ChecksumUnsupportedErrorinstead ofUnsupportedChecksumError) - Make names descriptive enough to understand the problem (use
MissingRequiredOrderErrorinstead ofOrderError) - Match existing conventions (like
AssociationNotFoundErrorfor consistency withHasManyThroughAssociationNotFoundError)
For method signatures:
- Choose concise yet descriptive names for parameters and methods
- Avoid overly verbose names like
supports_disabling_use_of_index_for_queries?whensupports_disabling_indexes?would suffice
Remember that code is read far more often than it’s written. Thoughtful naming reduces cognitive load for future readers.