Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Generally variables are named in the singular Car car; and arrays and list with the pluras: List<Car> cars; or Car[] cars; But what about nouns like fish or media* that are already plural?

*already lost the battle to have the class called Medium.

share|improve this question

closed as primarily opinion-based by durron597, gnat, MichaelT, Snowman, Dan Pichelman Aug 5 '15 at 18:06

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.

"fishes" is an acceptable plural form of of "fish", at least. – Izkata Jan 21 '14 at 2:52
I often use carList / carArray – Bryan Chen Jan 22 '14 at 3:13
up vote 4 down vote accepted

There are a couple of ways to tackle this problem. None of them are perfect, but you can find a workable solution. The key is that your team needs to come up with a standard approach to resolving this and to stick with it.

Here are some of the options:

  • Different capitalization

The singularly named variable will start with one case (lower case) while the plural variable will start with the other case (upper case).

 var Fish = new List<fish>();  //plural  
 var fish = Fish[0];           //singular
  • Deliberate use of improper grammar


 var Fishes = new List<fish>();  //plural  
 var fish = Fishes[0];           //singular  


 var Meese = new List<Moose>();  //plural  
 var Moose = Meese[0];           //singular
  • Use group name instead


 var SchoolOfFish = new List<Fish>();  //plural  
 var Fish = SchoolOfFish[0];           //singular
share|improve this answer

I think names like List<Fish> fish are perfectly fine. We use "fish" as both singular an plural in writing; why not do the same in code?

If you want a singular Fish fish in the same scope, say for iterating, can always switch to List<Fish> fishList or List<Fish> listOfFish.

share|improve this answer
List<Fish> school – Adrian Schneider Jan 21 '14 at 3:10
mostly because often you haves code conventions like for( Book book : books ) so the singular is already taken or going to be used for something else. – ArtB Jan 21 '14 at 14:44

My suggestion would be to try to use a more meaningful name for the list variables. I know this is sometimes hard to do, though.

For example, instead of List<Car> cars, use something like List<Car> parkedCars. Instead of Fish[] fish, use something like Fish[] availableFish.

share|improve this answer

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