Search code examples
naming

Variable naming convension for whether having


Variable for whether having, for example, the variable for if the user has points, which is correct?

have_points, has_points, if_having_points or if_has_points?


Solution

  • Naming convention for a variable which holds boolean value should be indicated by prefixes like: is, has, have, does, will, can etc.

    In your case you're using snake case. If "has Points" is being tracked for a single entity then you can go with has_points. For more than one entity you might want to go for have_points.

    Although it boils to personal preference, but you should still try to keep your code short and succinct.