Lesson 4: Naming Things: The Emotional Impact of Good Identifiers
Naming is arguably the hardest problem in Vibe Coding. A bad name forces the reader to stop, consult the surrounding code, and mentally map the vague name to its real meaning—a massive vibe sink.
The Vibe of Variables
Variables should answer What they hold and Why they hold it.
| Vibe Level | Example | Problem |
|---|---|---|
| Bad Vibe | tmp, i, data | Too vague. Requires context search. |
| Neutral Vibe | userList, calc | Acceptable, but could be clearer. |
| Good Vibe | pendingOrders, monthlyRevenueCalculation | Clear intent and type. |
Best Practices for Naming Variables
- Use Domain Language: If you work with financial data, use terms like
assetValuationrather thanx. - Avoid Mental Mapping: Don't use abbreviations unless they are universally accepted within your domain (e.g.,
HTTPis okay,custAcctis not). - Specify Units/Type (When Necessary):
userAgeInYears,timeoutMilliseconds.
The Vibe of Functions and Methods
Functions should be named like verbs or action phrases, answering What the code does.
| Entity | Convention | Example (Good Vibe) |
|---|---|---|
| Boolean Variables | Is/Has/Should | isLoggedIn, hasPermission |
| Functions (Actions) | Verb + Noun | fetchUserData, calculateTax |
| Classes/Objects | Noun | ShoppingCart, UserAuthenticator |
Example Vibe Shift
javascript // Bad Vibe: Ambiguous action function handle(a, b) { // ... }
// Good Vibe: Clear intent and parameters function processUserTransaction(userId, amount) { // ... }