Lexicon
⌘K
Explore
ExploreGuidesNotes
WriteMy LibraryBooks
Sign in
Browse

Bug Bounty

  • Only Bug Bounty Checklist You'll Ever Need!!!
  • Only Bug Bounty Checklist You'll Ever Need!!! V2

Databases

  • Database indexing basics

DevOps

  • How environment variables work

Discussions

  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • What's the tcp ip

Git

  • Git commands I use every day

JavaScript

  • JavaScript async and await

Kotlin

  • Kotlin coroutines overview

Linux

  • Useful Linux filesystem commands

Performance

  • How caching improves application performance

React

  • React component design principles

Reference

  • Markdown formatting reference

Software Craft

  • Clean code naming practices
  • Debugging checklist

SQL

  • SQL joins explained

Swift

  • SwiftUI state management

Web

  • API pagination patterns
  • Understanding HTTP status codes
New noteSuggest a guide

Lexicon

a personal knowledge base

← Back to note

Version history

No earlier versions yet — history builds up each time this note is edited.

Current version1 of 1

Software Craft

Clean code naming practices

Naming is the cheapest documentation you will ever write and the first thing the next reader sees. A good name removes the need for a comment.

Say what it is, not how it is stored

Name things after intent. activeUsers beats arr, isExpired beats flag.

// unclear
const d = users.filter((u) => u.a);

// clear
const activeUsers = users.filter((user) => user.isActive);

Make booleans read like questions

Prefix with is, has, can, or should so conditionals read like English: if (user.canEdit) reads better than if (user.edit).

Length should match scope

A loop index that lives for one line can be i. A value that lives across a whole module deserves a full, descriptive name. The wider the scope, the more the name has to carry.

Avoid noise words

UserData, UserInfo, and UserObject all mean the same thing as User. Words like Data, Info, Manager, and Helper often add characters without adding meaning.

Be consistent

Pick one term per concept and stick to it. If you fetch in one place, do not get, load, and retrieve elsewhere for the same operation. A reader should not have to wonder whether two different words mean two different things.

Functions are verbs, values are nouns

  • calculateTotal(), sendEmail(), parseDate() for actions
  • total, email, startDate for the things

The test

If you need a comment to explain what a variable holds, the name has already failed. Rename it and delete the comment.