re: How Do You Name Your Boolean Variables? VIEW POST

VIEW FULL DISCUSSION
 

Hungarian notation is dead and good riddance to it, but formulating boolean names as isX or hasX does a lot for clarity.

 
var hasGoodPoint = true;
var isMyConvention = true;

Also, I prefer not to pass booleans to (typically multi-argument) functions unless they are obviously expecting true or false (ie. property methods), so typically "can" or similar named functions:

This is okay:

canPost(true);

But this is not so good:

someMethod("Thing", true);

Some languages have named arguments, so in that case it'd be better to say:

someMethod("Thing", canDelegate=true);

Alternatively use enums:

someMethod("Thing", Delegation::Allowed);
code of conduct - report abuse