Prompt
Choose names that clearly reveal the purpose and behavior of variables, functions, and methods. Names should be self-documenting and follow these patterns:
- Boolean variables: Use
is,has, orshouldprefixes (e.g.,isInitialBuildSuccessfulinstead ofdiagnostics) - Async methods: Include action verbs that indicate the operation (e.g.,
loadStorybookInfo()instead ofstorybookInfo) - Function parameters: Use descriptive names instead of generic ones (e.g.,
before, afterinstead ofa, b) - Test descriptions: Avoid redundant words like “should” - prefer direct action descriptions (e.g.,
"initializes"instead of"should initialize")
Example improvements:
// Before
const diagnostics: boolean
async get storybookInfo()
function percentageDiff(a: number, b: number)
// After
const diagnosticsEnabled: boolean
async loadStorybookInfo()
function percentageDiff(before: number, after: number)
Well-named code reduces the need for comments and makes the codebase more maintainable by clearly communicating intent to other developers.