Prompt
Avoid abbreviations in variable, parameter, and method names to improve code readability and maintainability. Use descriptive identifiers that clearly indicate the purpose and content of what they represent.
Instead of:
// Abbreviated variable names
let spec = self.specialization;
let ctx = self.generic_context;
let ty = self.inferred_return_type();
let tvar = TypeVar(...);
Prefer:
// Descriptive variable names
let specialization = self.specialization;
let generic_context = self.generic_context;
let return_type = self.inferred_return_type();
let type_var = TypeVar(...);
Additionally:
- Functions should use verb phrases: use
infer_return_type()notinferred_return_ty() - Use meaningful variable names that match what they represent: if a variable holds a place expression, name it
place_exprnot justexpr - For generated/synthetic names (like type variables), use distinctive names that won’t conflict with common user code: use
T_allinstead of justT - Choose names that reflect the semantic meaning of the data, not just its type
Descriptive names make code easier to understand at first glance and reduce the cognitive load required to comprehend complex logic.