Skip to content

02. General coding style

Alex Parry edited this page Jan 23, 2023 · 1 revision

Avoid cognitive overload

Don’t do this Do this
Compound statement amount = int(input("Enter the amount")) response = input("Enter the amount")
amount = int(response)
Compound statement print(get_total(n1, n2)) total = get_total(n1, n2)
print(total)

Function names

Begin function and method names with a verb except where they are implementing a standard algorithm (in which case use the algorithm name).

For example, calculate_pay or validate_input (case depends on language used) or linear_search.

Class, structure, module, and property names

Begin class, structure, module, and property names with a noun.

For example, EmployeeName (case depends on language used)