The Art of Naming Variables: From x to Existential Crisis

There are only two hard problems in computer science: cache invalidation, naming things, and off-by-one errors. That’s right—three problems, and I meant that. Let’s talk about naming, because I recently spent 45 minutes trying to name a boolean that checks whether a user, who was invited by a partner between June and October 2023, verified their email using an OTP (not SMS, unless it’s fallback), and didn’t use SSO… all for a feature flag that might be deprecated by next sprint. I called it maybeQualifiedUserProbably. And I slept like a baby—woke up every 2 hours and cried. ⸻ Naming Variables is Just Therapy You Don’t Pay For Let’s look at how this usually goes: let a = getStuff(); let b = processStuff(a); let c = finalizeStuff(b); Congratulations, you’ve written a microservice that sounds like a toddler describing their day. So you try to improve it: let userData = getUserDataFromThirdPartyIfNotSSO(); let processedUser = validateUserWithOnboardingStatus(userData); let finalCheck = evaluateBusinessLogicThatNoOneUnderstands(processedUser); Now you’ve got something! Something long, slightly unhinged, and still utterly unhelpful when it throws a null pointer at runtime. ⸻ The 7 Stages of Naming a Boolean flag isFlag shouldEnable shouldEnableFeature shouldEnableNewFeature shouldEnableNewFeatureIfAdmin shouldEnableNewFeatureIfAdminAndNotSSOAndNotLegacyUser

Apr 22, 2025 - 08:56
 0
The Art of Naming Variables: From x to Existential Crisis

There are only two hard problems in computer science: cache invalidation, naming things, and off-by-one errors. That’s right—three problems, and I meant that.

Let’s talk about naming, because I recently spent 45 minutes trying to name a boolean that checks whether a user, who was invited by a partner between June and October 2023, verified their email using an OTP (not SMS, unless it’s fallback), and didn’t use SSO… all for a feature flag that might be deprecated by next sprint.

I called it maybeQualifiedUserProbably.

And I slept like a baby—woke up every 2 hours and cried.

Naming Variables is Just Therapy You Don’t Pay For

Let’s look at how this usually goes:

let a = getStuff();
let b = processStuff(a);
let c = finalizeStuff(b);

Congratulations, you’ve written a microservice that sounds like a toddler describing their day.

So you try to improve it:

let userData = getUserDataFromThirdPartyIfNotSSO();
let processedUser = validateUserWithOnboardingStatus(userData);
let finalCheck = evaluateBusinessLogicThatNoOneUnderstands(processedUser);

Now you’ve got something! Something long, slightly unhinged, and still utterly unhelpful when it throws a null pointer at runtime.

The 7 Stages of Naming a Boolean

  1. flag
  2. isFlag
  3. shouldEnable
  4. shouldEnableFeature
  5. shouldEnableNewFeature
  6. shouldEnableNewFeatureIfAdmin
  7. shouldEnableNewFeatureIfAdminAndNotSSOAndNotLegacyUser