DEV Community

Discussion on: Tips on naming boolean variables - Cleaner Code

Collapse
 
luigiminardim profile image
Luigi Minardi

isTwoLoggedIn?
areTwoLoggedIn?
isThereTwoLoggedIn?

What should it be? Any other option?

Collapse
 
michi profile image
Michael Z

That's a tough one.
What came to my mind was also
isPairLoggedIn
isPairOfUsersLoggedIn

Never ran into this case before though :D

Collapse
 
dlattynjt profile image
David Latty

Horrid

Collapse
 
stepanstulov profile image
Stepan Stulov • Edited

Two of whom? :)

twoUsersAreLoggedIn

Collapse
 
ultrox profile image
Marko Vujanic • Edited

You changed my mind with

Code is set of comands, it dosent ask questions it answers them.

Following that logic, you don't really need is as prefix, and naming of boolean follows the logic nicelly, much more readable, becouse I tryed changing all is to 'command', suprisingly it's just much more readable and parsable in by my head.

isSendEmailFetching -> (request is made to job to send email)
sendingEmail

I wonder what do you think about using transitive verb like this?

Thank you

Thread Thread
 
stepanstulov profile image
Stepan Stulov

Alternatively, in passive voice, emailIsBeingSent.

Collapse
 
dlattynjt profile image
David Latty

Good stuff