Boolean Naming Conventions: is, has, can, should
3 min read
Boolean names should read like yes/no questions. The four standard prefixes are is, has, can, and should.
Prefix Guide
| Prefix | Use For | Examples |
|---|---|---|
is | State/condition | isActive, isLoading, isValid |
has | Possession/existence | hasPermission, hasChildren |
can | Capability/ability | canEdit, canDelete |
should | Recommendation/expectation | shouldRedirect, shouldRetry |
Anti-Patterns
flag— flag for what?status— could be a string, not clearly booleancheck— sounds like a function, not a variable- Double negatives:
isNotDisabled— useisEnabled
Convert
camelCase for JS, snake_case for Python. Hub.