Skip to content

Instantly share code, notes, and snippets.

View akbarali1's full-sized avatar
🎯
Focusing

Akbarali akbarali1

🎯
Focusing
View GitHub Profile
@akbarali1
akbarali1 / Clean Code.md
Created June 21, 2024 04:25 — forked from evaera/Clean Code.md
Best Practices for Clean Code
  1. Use descriptive and obvious names.
    • Don't use abbreviations, use full English words. player is better than plr.
    • Name things as directly as possible. wasCalled is better than hasBeenCalled. notify is better than doNotification.
    • Name booleans as if they are yes or no questions. isFirstRun is better than firstRun.
    • Name functions using verb forms: increment is better than plusOne. unzip is better than filesFromZip.
    • Name event handlers to express when they run. onClick is better than click.
    • Put statements and expressions in positive form.
      • isFlying instead of isNotFlying. late intead of notOnTime.
      • Lead with positive conditionals. Avoid if not something then ... else ... end.
  • If we only care about the inverse of a variable, turn it into a positive name. missingValue instead of not hasValue.