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

PrefixUse ForExamples
isState/conditionisActive, isLoading, isValid
hasPossession/existencehasPermission, hasChildren
canCapability/abilitycanEdit, canDelete
shouldRecommendation/expectationshouldRedirect, shouldRetry

Anti-Patterns

  • flag — flag for what?
  • status — could be a string, not clearly boolean
  • check — sounds like a function, not a variable
  • Double negatives: isNotDisabled — use isEnabled

Convert

camelCase for JS, snake_case for Python. Hub.