Back to all reviewers

Purpose-revealing identifier names

pytorch/pytorch
Based on 3 comments
Python

Choose identifier names that clearly reveal their purpose and behavior. Names should be specific, descriptive, and self-explanatory: - **Function names** should include verbs that indicate the action being performed or a question being answered (e.g., use `is_consistent()` rather than `consistency()`)

Naming Conventions Python

Reviewer Prompt

Choose identifier names that clearly reveal their purpose and behavior. Names should be specific, descriptive, and self-explanatory:

  • Function names should include verbs that indicate the action being performed or a question being answered (e.g., use is_consistent() rather than consistency())
  • Class names should reflect the nature and purpose of the class (e.g., VersionString is better than generic VersionParser)
  • Method and variable names should be descriptive enough that comments aren’t needed to explain their purpose

Avoid vague or overly generic names that don’t communicate their specific role. When reviewing code, ask “Does this name clearly explain what it does or represents?”

Example:

# Less clear:
def contains_ungroupable(node):
    # Implementation...

# More clear:
def contains_gemm_like(node):
    # Implementation...

This naming approach reduces cognitive load for readers and makes code more maintainable over time by making its purpose immediately evident.

3
Comments Analyzed
Python
Primary Language
Naming Conventions
Category

Source Discussions