Use descriptive names

Choose names that clearly express the purpose, behavior, or semantic meaning of variables, functions, and types. Avoid ambiguous or generic names that require additional context to understand their role.

copy reviewer prompt

Prompt

Reviewer Prompt

Choose names that clearly express the purpose, behavior, or semantic meaning of variables, functions, and types. Avoid ambiguous or generic names that require additional context to understand their role.

Key principles:

  • Make boolean nature explicit: regexisRegex
  • Describe actual functionality: ParseDomainsAndRegexParseHostMatchers
  • Clarify behavior over generic terms: CustomResponseWriterStatusRecorder
  • Distinguish between similar concepts: FailTimeoutFailureWindow (time window vs timeout duration)
  • Be explicit about quantities: MaxFailsMaxFailedAttempts
  • Align with actual logic: downup when variable represents “up” status
  • Use explicit constants over magic values: defaultCacheDuration instead of cache.DefaultExpiration

Example:

// Ambiguous - what kind of timeout?
type PassiveHealthCheck struct {
    FailTimeout ptypes.Duration
    MaxFails    int
}

// Clear - describes the time window and explicit count
type PassiveHealthCheck struct {
    FailureWindow      ptypes.Duration
    MaxFailedAttempts  int
}

This approach reduces cognitive load, prevents misunderstandings, and makes code self-documenting.

Source discussions