DEV Community

Discussion on: A Grammar-Based Naming Convention

Collapse
 
stepanstulov profile image
Stepan Stulov • Edited

I disagree about booleans being questions. They need to be affirmative statements that evaluate to true or false. You code doesn't ask its reader a question, it gives an answer. But also, purely linguistically, compare:

if (isUserActive) // Bad
if (userIsActive) // Good

This also chains well with dot notation, compare:

bool isUserActive = user.isActive // Re-arranged, statement became question
bool userIsActive = user.IsActive // Word order preserved, remains a statement

Besides, throwing is/are/has/was/etc. to the beginning of the word smells like Hungarian notation, if you ask me.

"If is I developer" :)

Cheers

Collapse
 
somedood profile image
Basti Ortiz

Interestingly enough, I can definitely agree with this. Personally, I would stick with my convention solely for the fact that I've gotten used to it. As soon as I see a linking verb (such as "is" and "are") in the beginning of an identifier, I can immediately assume a Boolean value at first glance given that this naming convention only allows Boolean values to be represented by interrogative statements.

But this is not to discredit your suggestion, not at all. As said earlier, I can agree with it. It's just that I have grown accustomed to the way of thinking brought about by the naming convention in the article. In other words, it's just a matter of habit for me.