Choose names that clearly communicate the intent, behavior, and semantics of code elements. Names should be accurate, consistent, and follow established patterns:

  1. Method names must reflect what they operate on: If a method manipulates indices, name it accordingly (e.g., moveIndicesToPreviouslyFailedStep rather than moveClusterStateToPreviouslyFailedStep). Method names should express what they do, not how they do it.

  2. Variable names should precisely describe their content: Use terms that clearly convey meaning, especially for metrics or measurements:
    // Unclear - doesn't specify these are averages
    int percentWriteThreadPoolUtilization;
    long maxTaskTimeInWriteQueueMillis;
       
    // Clear - precisely describes the metrics
    int averageWriteThreadPoolUtilization;
    long averageWriteThreadPoolQueueLatency;
    
  3. Use consistent naming patterns: Follow established patterns within the codebase and respect external conventions:
  4. Prefer constants over string literals: Extract repeated or semantically meaningful strings into named constants:
    // Hard to maintain - string literals scattered throughout code
    if (configs.group.equals("unsupported") || configs.group.equals("union-types")) {
       
    // Better - using named constants
    private static final String GROUP_UNSUPPORTED = "unsupported";
    private static final String GROUP_UNION_TYPES = "union-types";
       
    if (configs.group.equals(GROUP_UNSUPPORTED) || configs.group.equals(GROUP_UNION_TYPES)) {