Back to all reviewers

Clear descriptive identifiers

deeplearning4j/deeplearning4j
Based on 3 comments
Java

Choose clear, self-descriptive names for all code identifiers that accurately reflect their purpose and behavior. Method names should be verbs or verb phrases that indicate their function without ambiguity. For boolean methods, use prefixes like "is", "has", or "should" followed by the condition they check.

Naming Conventions Java

Reviewer Prompt

Choose clear, self-descriptive names for all code identifiers that accurately reflect their purpose and behavior. Method names should be verbs or verb phrases that indicate their function without ambiguity. For boolean methods, use prefixes like “is”, “has”, or “should” followed by the condition they check.

When generating identifiers programmatically, use distinctive prefixes to avoid potential collisions with user-defined names. For example, prefer domain-specific prefixes like sd_var_ over generic ones like var_ to reduce collision risk.

// Avoid:
public final static boolean gilIsReleaseAutomatically() {} // awkward phrasing, hard to parse
private void parseSetupAndExecCode() {} // ambiguous, could mean "parse setup and execute code"
String varName = "var_" + _var_id.toString(); // too generic prefix

// Prefer:
public final static boolean releaseGilAutomatically() {} // direct and clear
private void parseSetupAndExecutionCode() {} // clearer alternative
// or better with JavaDoc explaining the purpose
/**
 * Parses both the setup code and execution code sections from the configuration.
 */
private void parseCodeSections() {}
String varName = "sd_var_" + String.valueOf(_var_id); // domain-specific prefix

Meaningful naming reduces the need for comments, improves code readability, and makes the codebase more maintainable for all developers.

3
Comments Analyzed
Java
Primary Language
Naming Conventions
Category

Source Discussions