Choose specific, descriptive names for variables, functions, types, and parameters that clearly indicate their purpose and avoid generic terms that could be overloaded or ambiguous. Generic names like `Command`, `Config`, or `Data` can become confusing when multiple similar concepts exist in the same codebase.
Choose specific, descriptive names for variables, functions, types, and parameters that clearly indicate their purpose and avoid generic terms that could be overloaded or ambiguous. Generic names like Command
, Config
, or Data
can become confusing when multiple similar concepts exist in the same codebase.
When naming identifiers, consider:
Example of improvement:
// Instead of generic name that conflicts with other Command types
type Command struct {
// ...
}
// Use specific, descriptive name
type NodeCLICommandMeta struct {
// ...
}
// Instead of ambiguous function name
func GetGlobalConfiguration() []ConfigOption {
// ...
}
// Use name that clearly indicates what is returned
func GetGlobalConfigurationOptions() []ConfigOption {
// ...
}
This practice prevents naming conflicts, reduces cognitive load when reading code, and makes the codebase more maintainable as it grows.
Enter the URL of a public GitHub repository