Prompt
Choose clear, consistent, and accurate identifiers that precisely reflect behavior and follow established patterns. This applies to function names, method names, variable types, and enum values.
For functions and methods:
- Ensure implementation names match their API registration (e.g., use
"fail"inIDLOperation::callto match the prototype table registration) - Choose names that reflect complete behavior including edge cases (e.g., use
getIndexinstead ofgetDirectIndexwhen properties might be getters) - Consider creating more descriptive methods like
isInt32AsAnyIntinstead ofisUInt32()when the method handles multiple input formats
For types and constants:
- Prefer standardized type names (e.g.,
int64_toverlong long) for better portability - Align enum values with established API conventions (e.g., using
utf16to match Node.js’snapi_get_value_string_utf16)
Consistent and precise naming reduces bugs from misinterpreting an identifier’s purpose, improves code readability, and makes integration with other libraries more intuitive.