Use clear, descriptive identifiers that accurately reflect their purpose, and maintain consistent naming patterns throughout the codebase. This applies to variables, parameters, methods, and configuration elements.
Use clear, descriptive identifiers that accurately reflect their purpose, and maintain consistent naming patterns throughout the codebase. This applies to variables, parameters, methods, and configuration elements.
For variables:
$params
in favor of more specific names like $invokeParams
For configuration elements:
Example of improved variable naming:
# Poor naming - generic and potentially confusing
$params = @{
Method = 'GET'
Uri = $uri
}
return Invoke-RestMethod @params
# Better naming - clearly indicates purpose
$invokeParams = @{
Method = 'GET'
Uri = $uri
}
return Invoke-RestMethod @invokeParams
Example of consistent naming in configuration:
<!-- Inconsistent naming pattern -->
<PackageReference Remove="System.Text.Json" />
<PackageReference Remove="System.Threading.Tasks.Extensions" />
<PackageReferences Remove="System.Memory" />
<!-- Consistent naming pattern -->
<PackageReference Remove="System.Text.Json" />
<PackageReference Remove="System.Threading.Tasks.Extensions" />
<PackageReference Remove="System.Memory" />
Descriptive and consistent naming reduces cognitive load for readers, prevents errors from misused variables, and makes the codebase more maintainable.
Enter the URL of a public GitHub repository