Use descriptive, self-explanatory names for variables, methods, fields, and types. Avoid single-letter variables, abbreviations, and generic naming that obscures intent.
Key principles:
id_value
instead of v
, customer
instead of c
mandate_type
instead of action_type
, is_sdk_client_token_generation_enabled
instead of is_sdk_session_token_generation_enabled
id_type::CustomerId
instead of String
for customer identifiersAuthenticationStatus::Y
instead of "Y"
client
instead of superposition_client
when the struct name already indicates contextconst ITEM_TYPE: &str = "plan"
instead of inline stringsExample:
// Poor naming
let c = &item.response.customer;
let n = c.name.as_ref().map(|n| n.clone().expose());
pub customer_id: String,
pub payment_method: String,
// Good naming
let customer = &item.response.customer;
let customer_name = customer.name.as_ref().map(|name| name.clone().expose());
pub customer_id: id_type::CustomerId,
pub payment_method: PaymentMethodType,
Clear, meaningful names reduce cognitive load, improve code maintainability, and make the codebase more accessible to new developers.
Enter the URL of a public GitHub repository