Choose names that clearly communicate intent and purpose rather than being generic, abbreviated, or potentially misleading. Names should accurately reflect what the code does, not how it does it.
Choose names that clearly communicate intent and purpose rather than being generic, abbreviated, or potentially misleading. Names should accurately reflect what the code does, not how it does it.
Key principles:
column_idx
instead of field_idx
for database operations)SerializeToDisk
instead of GetStorageInfo
, LogFailure
instead of LogBoth
)supports_ordinality
instead of ordinality_implemented
)"replace"
instead of "r"
for error handling modes)match_actions.size()
instead of hardcoded 3
)extension_loading = none
when it actually loads extensions)Example:
// Avoid generic or misleading names
void GetStorageInfo(optional_ptr<ClientContext> context, bool all_expr_inputs_valid);
for (idx_t match_idx = 0; match_idx < 3; match_idx++) { // magic number
// Use descriptive, intent-revealing names
void SerializeToDisk(optional_ptr<ClientContext> context, bool all_inputs_valid);
for (idx_t match_idx = 0; match_idx < match_actions.size(); match_idx++) { // named constant
This approach makes code self-documenting and reduces the cognitive load for developers reading and maintaining the codebase.
Enter the URL of a public GitHub repository