Choose variable, function, and type names that preserve cognitive context by clearly indicating their purpose and relationship to surrounding code. Names should help readers understand the code's intent without having to deeply analyze implementation details.
Choose variable, function, and type names that preserve cognitive context by clearly indicating their purpose and relationship to surrounding code. Names should help readers understand the code’s intent without having to deeply analyze implementation details.
Examples:
// Poor naming - loses context
ctx := someFunc(refs)
psuedo := value.Decode()
targetedNodes := getExcludedItems()
// Good naming - preserves context
hclCtxFunc := someFunc(refs) // Indicates it returns HCL context
decodedExpectedVar := value.Decode() // Shows relationship to expected value
excludedNodes := getExcludedItems() // Matches exclusion logic
This practice reduces cognitive load when reading code by:
When choosing names, consider:
Enter the URL of a public GitHub repository