Choose names that clearly convey purpose and intent rather than generic or ambiguous terms. Prefer specific, descriptive terminology that makes code self-documenting and reduces cognitive load for readers.
Key principles:
file_reader
is more precise than content_reader
when the function reads entire filescharset_normalizer.from_path
is more meaningful than a bare from_path
importIntEnum
with named values instead of raw int
for severity levelsExample improvements:
# Less clear
from charset_normalizer import from_path
def get_extracts(content_reader: Callable[[str], str]):
severity: int = 1
# More semantically meaningful
import charset_normalizer
def find_code_snippets(file_reader: Callable[[str], str]):
severity: DiagnosticSeverity = DiagnosticSeverity.ERROR
result = charset_normalizer.from_path(path)
This approach makes code more maintainable by reducing ambiguity and making the developer’s intent explicit through careful name selection.
Enter the URL of a public GitHub repository