Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 992419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:15:53+00:00 2026-05-16T06:15:53+00:00

Very often when you code you have a flag indicating two possibilities, like this:

  • 0

Very often when you code you have a flag indicating two possibilities, like this:

CACHING_AUTHORIZED
CACHING_UNAUTHORIZED

or

CACHING_ON
CACHING_OFF

If you then use a boolean to store this, very often it just “reads weird”:

CACHING_ON = false;
CACHING_OFF = true;

or

CACHING_ON = true;
CACHING_OFF = false;

One of the possibility is to write:

CACHING

And then simply code using:

if ( CACHING )

or

if ( !CACHING )

but sometimes you really do want both the ‘ON’ and ‘OFF’ forms.

The thing is: it doesn’t change much which one you pick, it simply doesn’t make much sense, no matter how you turn it.

It is not entirely dissimilar to the “getter” problem for boolean, which is certainly subject to a lot of heated debate (should we use isConditionTrue or getIsCondition or isCondition or getCondition or simply condition or conditionTrue etc.: I’m being a bit facetious but the point stands and there have been very long debates on this and the topic certainly ain’t close).

My question is different: seen that neither

CACHING_ON = false;
CACHING_OFF = true;

nor

CACHING_ON = true;
CACHING_OFF = false;

make sense, shouldn’t we simply get rid of the boolean and do:

CACHING_ON = 1;
CACHING_OFF = 2;

Sure, you’re losing the boolean but at least ‘1’ and ‘2’ cannot bring any confusion.

My point is: using a boolean and true/false is very often confusing because we’re mixing two different things: english and logic and they simply, well, don’t mix at all.

Is it bad to use an int here even tough there are only two possibilites?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:15:54+00:00Added an answer on May 16, 2026 at 6:15 am

    Your method makes it unclear the value is a boolean. I feel like I should be able to assign the value 3.

    I don’t really get your point. If you have 2 booleans you’re representing 4 possible states so you shouldn’t really be naming the variables in a way that suggests there are only 2 options. Maybe you should be using an enum and constants or flags instead.

    CACHING = ON
    CACHING = OFF
    CACHING = EITHER
    CACHING = UNKNOWN
    CACHING = UNKNOWABLE
    CACHING = UNTHINKABLE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

very often I like to have my movieclip code inside the movieclip (on a
I have the following line of code called very often: var configValue = System.Configuration.ConfigurationManager.AppSettings[ConfigValueKey];
I'm finding this kind of overriding after a new in java code very often
I get this error in xml file very often. here is the code in
When I'm writing code with QtCreator (2.4.1), I'm very often in this situation: something
I have some synchronization in my Objective-C project. The code looks like this: -
Yeah! its me again - seems like I have to ask you very often
I have a very frustrating python problem. In this code fixedKeyStringInAVar = SomeKey def
I have some Vaadin code blocking very often here, and I have no idea
Very often when Visual Studio generates code (for example generating an event handler stub)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.