Chris said:
As someone who is exactly anal retentive enough to care about this... I
started out many years ago using singular forms for arrays, and plurals
for the remainder. I did it for exactly the same reason someone else
mentioned: the array access syntax "sounded" better. After about six
months of serious work, I realized that this was ridiculous, and
switched.
I think arrays are the only one that there seems to be a disagreement.
The concensus seems to be that for collections you either use plural or
a word that describes a group (e.g. goatHerd).
IMO, the best argument for switching is that arrays aren't ALWAYS used
for indexing. Sometimes array references are passed around in their own
right. For example, I may pass an entire array reference to a method.
In that case, it's incredibly awkward and inexplicable to use "goat"
instead of "goats". I eventually realized that my naming conventions
were catering to a limited subset of the language and lacked the
essential property of closure over the entire language.
I agree with your reasoning but come to a different conclusion. I agree
is is awkward to use the singular when you deal with the group as a
whole. But it is also awkward to use the plural when indexing. That is
why I don't believe the choice for arrays is an either or. I think the
choice on which to use depends on the array and how it is used. I will
use the singular form when primarily using array indexing, but use
plural when the array is referred to as a whole for a significant amount.
So I agree that using the singular is catering to a limited subset of
the language, but if that is where the array is primarily used then I
follow that convention.
But as someone pointed out the use of array indexing is much less with
foreach.