Prompt
Choose names that clearly communicate intent without requiring mental gymnastics to understand. Avoid double negatives in variable names, maintain consistent naming patterns across the codebase, and ensure names accurately describe their purpose and context.
Key principles:
- Avoid double negatives: Instead of
pythonNoGlobalHandlersrequiring!pythonNoGlobalHandlers, use positive naming likelegacyGlobalHandlers - Be descriptive and contextual: Function names should clearly indicate what they do and include relevant context (e.g.,
nodeCompatHttpServerHandlerinstead of genericregisterFetchEvents) - Maintain consistency: If using
Moduleas a parameter name throughout the codebase, stick with it consistently, or rename the type toModuleTypeto allow lowercasemoduleparameters
Example of improvement:
// Avoid - requires double negative
export const pythonNoGlobalHandlers: boolean = !!compatibilityFlags.python_no_global_handlers;
if (!pythonNoGlobalHandlers) { ... }
// Prefer - clear positive naming
export const legacyGlobalHandlers: boolean = !compatibilityFlags.python_no_global_handlers;
if (legacyGlobalHandlers) { ... }