20

When using variables of which their plural and singular are both the same, how do you name them? Are there any standards out there?

For example:

Series[] series  // Plural
Series series    // Singular

Indepth:

To be specific, my collection of series needs to be called series (due to JSON formatting), would you consider naming the singular form of Series that gets added to the collection Series s?

As in:

List<Series> series = new List<Series>();
Series s;

while (someBool)
{
    s = new Series();
    s.Name = "Name";
    while (anotherBool)
    {
        s.AddValue(someValue);
    }
    series.Add(s);
}
anthonytimmers
  • 319
  • 1
  • 5
  • 4
    I usually distinguish them by adding the type of collection they are stored in into their name, such as `seriesList`, `seriesArray` or `seriesLinkedList`. I don't think there's a naming standard. – Andy Sep 24 '15 at 11:18
  • 8
    +1 for pluralia tantum! I guess it depends on what the `series` is. For instance if it were a television series (I am speculating here) a single element could be an `episode` - although that does feel a little messy to me. Are there any synonyms that make sense to your model? I once happened across a fairly horrific solution in some code I was maintaining - it would technically work for you: use gollum-speak; e.g: `serieses`. Not that I am suggesting you do that - definitely not! :D – Darragh Enright Sep 24 '15 at 11:18
  • 3
    @Darragh When talking with my colleagues about the series, the occasional "serieses" does occur when trying to accentuate that we're speaking of the collection ;) – anthonytimmers Sep 24 '15 at 11:24
  • I just stumbled upon this very problem recently, when ReSharper proposed the name timeSerieses for a List, not the best solution, though – Paul Kertscher Sep 24 '15 at 12:21
  • Yeah, the problem is like I stated that the plural has to be named series. So I've called the singular form `singleSeries`, which sounds like a new kind of genre. But in all seriousness, would you find a name like that readable and understandable? – anthonytimmers Sep 24 '15 at 14:30
  • 1
    Since you can't change the name of your list, in that sample, I would call it newSeries – the_lotus Sep 24 '15 at 15:55
  • 1
    Is it an option to call it `Series[] serieses`, or is that too Gollum-y? – Jules Sep 24 '15 at 17:02
  • 1
    "Series" is not a plurale tantum. A plurale tantum is a plural form for which there is no singular form, not a plural form identical to the singular form. – joriki Sep 24 '15 at 17:53
  • @joriki Not sure if it's a singular or plurale tantum. It doesn't matter too much as the question still stands. Out of pure interest, is there a name for a noun that has the SAME singular as plural? – anthonytimmers Sep 24 '15 at 17:57
  • @anthonytimmers: You can call them "invariant" or "invariable" -- see http://english.stackexchange.com/questions/45039/is-there-a-term-for-words-that-have-identical-singular-and-plural-forms and https://en.wiktionary.org/wiki/Category:English_invariant_nouns. – joriki Sep 24 '15 at 17:59
  • A plurale tandum is a noun that only exists in a plural form to describe a singular item, eg trousers or scissors. Plurals are then expressed as pairs of trousers etc. Series is not a plurale tantum. You can have one series, two series etc. The singular and plural and the same word. So the answer to your specific question is using `series` to name both a single series and a collection of series is grammatically correct and thus a good, readable solution. – David Arno Sep 24 '15 at 20:27

1 Answers1

18

I do not think there is a standard for this. The majority of english nouns does not come with this problem. So if you do not want to add a term like "list" or "collection" to the variable name, a possible solution is to circumvent that problem by simply choosing a different term.

In your example, one could use "sequence" instead of "series" (if that is the meaning of "series" you had in mind).

Of course, for some words like "spectacles" or "trousers" finding an appropriate synonym which fits to your context might not be easy. For those it is probably the best solution to follow @DavidPacker's suggestion to use a word like "spectaclesCollection" or "trousersList".

Doc Brown
  • 199,015
  • 33
  • 367
  • 565
  • I would avoid naming the trousers trouserList since it could misrepresent the type behind it. Being that C# is tagged in the question I think XxxCollection is better since ICollection is an interface and not a specific implementation. – Ziv Oct 07 '15 at 11:42