Let's suppose that I need to store the number of foo objects in a variable.
Not being a native English speaker, I always wonder what's the best (= short and immediately clear) name for that var.
foo_num
? num_foo
? no_foo
? foo_no
? or something else?
The full name should be number_of_foos
, but it's a bit verbose.
What's your favorite and why?
I go for fooCount
because it is straightforward, and I think the word "count" is the shortest and the best that describes it, not "number of" or the like.
I go for FOO_COUNT
if it you need to store it final and static(if you don't need to change it/if it is a constant). (all caps for constants!)
I go for count
and calling it by Foo.count
if you really have to store it as an attribute for a class that you made, which is Foo
.
readability for you and for your team!