Choose specific, descriptive names for variables, methods, types, and other identifiers that clearly communicate their purpose and behavior. Avoid generic names, unnecessary abbreviations, and assumptions about usage context.
Choose specific, descriptive names for variables, methods, types, and other identifiers that clearly communicate their purpose and behavior. Avoid generic names, unnecessary abbreviations, and assumptions about usage context.
Key principles:
_allNativeContexts
instead of _allContexts
when the method only returns native contexts)InstalledBrowserInfo
instead of Options
)typedArrayConstructors
instead of typedArrayCtors
)alreadyRegistered
instead of foo
)getAllByAria
if it’s not exclusively for aria purposes)Example:
// Avoid generic or abbreviated names
type Options = { ... }; // ❌ Too generic
const typedArrayCtors = { ... }; // ❌ Unnecessary abbreviation
// Use descriptive, specific names
type InstalledBrowserInfo = { ... }; // ✅ Clear purpose
const typedArrayConstructors = { ... }; // ✅ Full, clear name
// Method names should reflect actual behavior
_allContexts() { return this._browserTypes().flatMap(...); } // ❌ Misleading scope
_allNativeContexts() { return this._browserTypes().flatMap(...); } // ✅ Accurate scope
This approach improves code readability, reduces confusion, and makes the codebase more maintainable by ensuring identifiers clearly communicate their intended purpose.
Enter the URL of a public GitHub repository