Back to all reviewers

Descriptive specific names

spring-projects/spring-framework
Based on 8 comments
Java

Choose names that are specific, descriptive, and accurately reflect the purpose and domain of variables, methods, classes, and constants. Avoid overly generic terms that could be ambiguous or conflict with future features.

Naming Conventions Java

Reviewer Prompt

Choose names that are specific, descriptive, and accurately reflect the purpose and domain of variables, methods, classes, and constants. Avoid overly generic terms that could be ambiguous or conflict with future features.

When naming constants, qualify them to avoid collisions:

// Avoid
public static final String ATTRIBUTES_CHANNEL_KEY = "attributes";

// Prefer
public static final String ATTRIBUTES_CHANNEL_KEY = 
    ReactorClientHttpRequest.class.getName() + ".attributes";

For methods, use names that clearly describe their specific purpose:

// Too generic
private PreparedStatementCallback<int[]> getPreparedStatementCallback(...) { }

// More descriptive
private PreparedStatementCallback<int[]> getPreparedStatementCallbackForBatchUpdate(...) { }

For parameters and variables, select names that accurately reflect their type and domain:

// Potentially confusing (suggests java.nio.ByteBuffer)
public DataBuffer encodeValue(ByteBuf byteBuffer, ...) { }

// Clear and accurate
public DataBuffer encodeValue(ByteBuf byteBuf, ...) { }

When adding similar methods to existing APIs, choose names that align with established patterns:

// Doesn't align with Optional's terminology
UriBuilder optionalQueryParam(String name, Optional<?> optionalValue);

// Aligns with terminology and sorts better alphabetically
UriBuilder queryParamIfPresent(String name, Optional<?> optionalValue);
8
Comments Analyzed
Java
Primary Language
Naming Conventions
Category

Source Discussions