19

Possible Duplicates:
“User accounts” or “users account?”
Is it correct to say “lesson count” or “lessons count”?

I'm wondering whether or not I should use a plural form noun with a collection name. For example, which one is correct, bookList or booksList (obviously they are variables in a programming language)?

2
  • 1
    variable_names (I don't like CamelCase much :-) are better off following rules of logic rather than rules of English. If this isn't a dup, it must be off-topic.
    – user1579
    Commented Mar 22, 2011 at 15:01
  • @Rhodri: CamelCase is generally a preference of the language being used. I would advice against fighting the norm if anyone else needs to read your code; your discomfort is less than the discomfort of everyone following behind you.
    – MrHen
    Commented Mar 22, 2011 at 15:30

5 Answers 5

16

I'd prefer bookList. After all, nobody uses a books shelf, either, but a book shelf.

9

Why aren't you using books instead of bookList? If this is in an object oriented language, the variable will be declared as List *books which clarifies that books is a List.

Putting the variable type in the variable is fine but it isn't needed as much as it was in the past. If you really want "list" in the var name somewhere I would recommend bookList if it is a list of Book objects (or whatever you are using for a book.)

I would never use booksList. If you are storing lists of lists of books I would recommend finding a term other than "book." Library, shelf or bookLists may work. Essentially, a plural at the end of a variable flags it as a container for objects of whatever was just pluralized. books is a container of book. cats is a bag of cat. dogLists is a container of dogList.

3
  • Use bookList to store a list of individual books.
  • Use booksList (or bookListList) to store a list of lists of books.
1
  • For the second example I would prefer bookLists instead of booksList.
    – Fer
    Commented Sep 13, 2022 at 6:56
2

The first thing I think of is Booklist magazine, a reasonably well-known publication of the American Library Association.

I'd go with bookList regardless, because it's easier to say (or subvocalize).
But I think both are reasonable forms, so if you like one or the other, go with that one.

0

List implies a collection of objects, the object type in the variable name implies that each element in the collection is a single Book as opposed to each element being another collection of Books, in the plural.
If the second case were true, and we were dealing with a multi dimensional array of objects, it would make more sense to use different collective noun to describe the outer collection rather than Books.

e.g.

  • libraryList is a list of libraries, each library contains a bookshelfList
    • bookshelfList is a list of bookshelves, each bookshelf contains a bookList
      • bookList is a list of books

Not the answer you're looking for? Browse other questions tagged or ask your own question.