← Back to Learn
FundamentalsBeginner8 min read

The Zen of Variable Naming

Learn how human developers choose names that tell stories, while AI defaults to generic patterns.

Variable names are more than labels—they're tiny narratives. When a human names a variable userPreferences, they're thinking about context. When an AI names it data, it's just a placeholder.

The Tale of Two Developers

Imagine you're reading a book where every character is named "Person". That's what reading AI-generated code often feels like.

Human Style

javascript
// Context-aware naming
const activeUserCount = users.filter(u => u.isOnline).length;

// Intent is clear
const shouldNotify = hasNewMessage && !isMuted;

// Domain language
const shoppingCart = {
  items: [],
  addProduct: (item) => { /*...*/ }
};

AI Style

javascript
// Generic naming
const result = data.filter(item => item.value).length;

// Verbose but vague
const conditionCheck = variable1 && !variable2;

// Lost context
const object1 = {
  array1: [],
  function1: (param1) => { /*...*/ }
};

Key Principles

1. **Use Domain Language**: If you're building a recipe app, use `ingredients`, not `items`. If it's a finance app, use `transaction`, not `record`.
2. **Reveal Intent**: `isEligibleForDiscount` tells a story. `check` does not. Boolean variables should often sound like questions (`isActive`, `hasAccess`).
3. **Embrace Specificity**: AI loves `data`, `info`, and `result`. Humans reach for `customerProfile`, `weatherForecast`, and `finalScore`.
**Pro Tip:** Read your variable names out loud. If they sound like a conversation, you're on the right track. If they sound like a computer talking to itself, it's time to refactor.

Up Next

Refactoring AI Spaghetti

Read Guide →
Vibe Code Detector