Skip to content

02. General coding style

Diane Dowling edited this page Apr 11, 2025 · 2 revisions

Avoid cognitive overload

Don’t do this Do this
Combined statement amount = int(input("Enter the amount")) response = input("Enter the amount")
amount = int(response)
Combined 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)

Clone this wiki locally