Choose descriptive and semantic identifiers that clearly convey purpose, role, and behavior. Avoid vague, generic names in favor of specific ones that enhance code readability and self-documentation.
Choose descriptive and semantic identifiers that clearly convey purpose, role, and behavior. Avoid vague, generic names in favor of specific ones that enhance code readability and self-documentation.
Key practices:
# Poor naming
new_value = [*vertex.attributes[property], *value]
# Better naming
list_updated_value = [*vertex.attributes[property], *value]
# Misleading (returns boolean)
def _prioritise_secrets(secret_records, secret_key, check_id):
# Clear and accurate
def _should_prioritise_secrets(secret_records, secret_key, check_id):
# Ambiguous - multiple "Runner" classes in codebase
class Runner(TerraformRunner):
# Clear and specific
class TerraformJsonRunner(TerraformRunner):
# Inconsistent
self.dataflow = data_flow
# Consistent
self.data_flow = data_flow
# Potentially confusing with standard library
def deepcopy(obj: _T) -> _T:
# Clear it's a custom implementation
def pickle_deepcopy(obj: _T) -> _T:
When iterating over collections, use descriptive variable names instead of generic ones:
# Vague
for each in resource_changes:
# ...
# Descriptive
for changed_resource in resource_changes:
# ...
Enter the URL of a public GitHub repository