Is naming Booleans that start with "is" bad practice now? My manager believes that "isAnything" is outdated and poor practice. Is this true?
myManager.isLame ? correct() : incorrect();
[Mandatory] Do not add 'is' as prefix while defining Boolean variable, since it may cause a serialization exception in some Java frameworks.
When naming booleans, you should avoid choosing variable names that include negations. It's better to name the variable without the negation and flip the value. If you absolutely can't (see Guideline 2 below), then try to find an already-negated form of the concept you are trying to express.
To declare a Boolean variable, we use the keyword bool. To initialize or assign a true or false value to a Boolean variable, we use the keywords true and false.
It's used quite often in a lot of languages, but I don't know if it can be said with certainty that it's the preferred method.
I think consistency and everyone on a given team using the same standards/styles is the important thing to bear in mind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With