Programming Popular

Name Booleans Like Yes/No Questions

Boolean variables named "active", "permission", or "valid" are ambiguous — is it a status, a check, or an action? Prefix booleans with is, has, can, should, or...

Problem

Boolean variables named "active", "permission", or "valid" are ambiguous — is it a status, a check, or an action?

Solution

Prefix booleans with is, has, can, should, or was. They read like questions: isActive, hasPermission, canEdit.

Benefit

Code reads like English. "if (isActive && hasPermission)" is instantly understandable vs "if (active && permission)".

Code Example

// Bad — ambiguous
let active = true;
let permission = false;
let valid = true;

// Good — reads like a question
let isActive = true;
let hasPermission = false;
let isValid = true;

// Now code reads naturally:
if (isActive && hasPermission && !isDeleted) {
    // Allow access
}

ES
Edrees Salih
7 hours ago

We are still cooking the magic in the way!