-
Meaningful Names: Name variables and functions to reveal their purpose, not just their value.
-
One Function, One Responsibility: Functions should do one thing.
-
Avoid Magic Numbers: Replace hard-code values with named constants to give them meaning.
-
Use Descriptive Booleans: Boolean names should state a condition, not just its value.
-
Keep Code DRY: Duplicate code means duplicate bugs. Try and reuse logic where it makes sense.
-
Avoid Deep Nesting: Flatten your code flow to improve clarity and reduce cognitive load.
-
Comment Why, Not What: Explain the intention behind your code, not the obvious mechanics.
-
Limit Function Arguments: Too many parameters confuse. Group related data into objects.
-
Code Should Be Self-Explanatory: Well-written code needs fewer comments because it reads like a story.