Prompt
Select parameter and method names that accurately describe their purpose and behavior, avoiding ambiguous terms that can lead to confusion. Consider these guidelines:
- Use descriptive names that reflect the actual behavior:
// AVOID: Parameter name doesn't clearly indicate truncation behavior pub fn truncate(&mut self, max_len: usize, stride: usize, left: bool) { // ... } // BETTER: Use an enum with meaningful names pub fn truncate(&mut self, max_len: usize, stride: usize, direction: TruncationDirection) { // ... } - Follow language-specific naming conventions:
- In Python interfaces, use lowercase for enum values (
"first"instead of"First") - In Rust, avoid leading underscores for public functions (
from_stringnot_from_string)
- In Python interfaces, use lowercase for enum values (
- Choose names that prevent confusion between related but different concepts:
// AVOID: Similar method names with different behaviors fn add_tokens(&mut self) { /* ... */ } fn num_added_tokens(&self) { /* ... */ } // BETTER: Clear distinction in naming fn add_tokens(&mut self) { /* ... */ } fn num_special_tokens_to_add(&self) { /* ... */ }
When choosing identifiers, always ask: “Would another developer immediately understand what this name represents without looking at its implementation?”