Prompt
Variable, method, and type names should precisely reflect their actual content, purpose, or scope. Names that misrepresent what they contain or do create confusion and make code harder to understand and maintain.
Ensure that:
- Type names match their actual structure (use
PartialLocaleTypefor partial implementations, not the fullLocaleType) - Variable names correspond to their context (use
const no: LocaleTypefor Norwegian locale, notconst en: LocaleType) - Parameter purposes are clear through naming and explicit defaults
Example of problematic naming:
// Misleading - suggests full locale but may be partial
import { LocaleType } from "./index";
// Confusing - Norwegian locale named as English
const en: LocaleType = {
// Norwegian translations...
};
Example of semantically accurate naming:
// Clear - indicates partial implementation
import { PartialLocaleType } from "./index";
// Accurate - matches the actual locale
const no: LocaleType = {
// Norwegian translations...
};
// Explicit default parameter
export function getHeaders(ignoreHeaders: boolean = false) {
// ...
}
This practice makes code self-documenting and reduces cognitive load when reading and maintaining the codebase.