Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Let's say we have a class that represents a Sudoku grid. In that grid we have a collection of cells. Now, if I simply made a collection of these cells accessible through the class the naming it would be pretty straight forward. I would use the plural:

Public List<CellClass> Cells

But what if I wanted to use a square array so that I can easily get a cell at a certain coordinate. Will it be:

Public CellClass[,] Cells


Public CellClass[,] Cell

Using a plural sounds intuitive enough since it's a collection, but then you access it like this:

x = myBoard.Cells[2,3]

Which doesn't look nearly as nice (and grammatically correct) as:

x = myBoard.Cell[2,3]

So what do you think would be better? Plural or singular?

share|improve this question

closed as primarily opinion-based by Dan Pichelman, MichaelT, gnat, Kilian Foth, GlenH7 Oct 4 '13 at 11:16

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

i usually go with the plural unless the name itself has something like group or collection in it. –  Ray Tayek Oct 3 '13 at 19:09
in Excel VBA(Visual Basic for Application) used Cells(rowNumber, ColumnNumber) –  Fabio Oct 3 '13 at 19:10

3 Answers 3

up vote 15 down vote accepted

Actually, if you're employing good naming and encapsulation, you are more likely to access it like this:

cell = Cells[2,3]

or like this:

foreach cell in Cells

In those cases, using the plural on the array makes it much more clear whether you're referring to a collection or not, without having to refer back to the type. If you use the singular form for the collection, you end up needing to make weird names for the single item, like currentCell or x.

share|improve this answer

In layman's words:

  • Use the plural. That's the way you will find in most books.
  • If you use the singular, then you may write the following that is more grammatically irritating than Cell[2,3]:

    Collections.sort(cell) // looks like sorting a single cell !

share|improve this answer

This question will probably elicit a few different opinions, but honestly when it comes to naming conventions there is one convention to rule them all.

Pick a convention and stick with it.

It ultimately doesn't matter what the naming convention is as long it recognizable throughout your code. I can practically guarantee if you look at several code samples done by different people/organizations you will see different naming conventions. None of them are necessarily right or wrong. The most important thing is for there to be consistency throughout the codebase, and hopefully through an organization.

share|improve this answer

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