Prompt
Use descriptive, self-explanatory names for variables, methods, fields, and types. Avoid single-letter variables, abbreviations, and generic naming that obscures intent.
Key principles:
- Use descriptive variable names instead of single letters:
id_valueinstead ofv,customerinstead ofc - Make method and field names self-explanatory:
mandate_typeinstead ofaction_type,is_sdk_client_token_generation_enabledinstead ofis_sdk_session_token_generation_enabled - Use domain-specific types instead of primitives:
id_type::CustomerIdinstead ofStringfor customer identifiers - Use enums instead of string literals for categorical data:
AuthenticationStatus::Yinstead of"Y" - Avoid redundant naming: use
clientinstead ofsuperposition_clientwhen the struct name already indicates context - Use constants for hardcoded values:
const ITEM_TYPE: &str = "plan"instead of inline strings
Example:
// 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.