Kind of an English question: using the plural in the first part of an identifier name

As a non-native English speaker, I often wonder about the use of the plural form in the initial part (s) of nominal phrases when assigning classes or objects.

For example:

  • If I have an interface for several [streaming] players, is that good English to call it PlayersInterface , unlike PlayerInterface , which is a single player interface?

  • If there is a service that handles events, can I call it EventsService ? Or is the sound of an EventService significantly better?

Thank you for your help!

EDIT:

  • Obviously, in .NET, the interface name started with I Therefore, modify the example a little and name it PlayersGateway .

  • I do not have another class named PlayerInterface (or PlayerGateway ). It was just an example of an alternate name that I would use if I only needed a single player interface. I think that the use of both PlayerGateway and PlayersGateway in the same project is difficult to maintain, so as not to say evil to future team members. Therefore, please assume that there is no PlayerGateway , just PlayersGateway .

+6
language-agnostic c # naming-conventions domain-driven-design vocabulary
source share
4 answers

In English, when you insert a noun next to another noun to change it, you usually use the only one:

  Coat Room Guard Tower 

although the room may have several layers or guards in the tower. IMHO, the variable name must follow the general rules of the language.

+7
source share

I believe that you should usually use a singular wording of the word. For example, if you had a Car class, and you had a class that had many instances of the Car class, you would call it CarCollection instead of Cars

+8
source share

I would like to use the singular. An EventHandler or EventService would have a connotation that it would handle one event after another. For video players, I could make sure you said that you connected to several players and controlled them all at the same time.

Do you have a second type / variable for the singular case?

 PlayersInterface AllPlayers = new PlayersInterface(); PlayerInterface MyPlayer0 = AllPlayers.getPlayer(0); PlayerInterface MyPlayer2 = AllPlayers.getPlayer(1); 

Even then, I think the names of the two types are too similar.

But this is a personal preference.

+1
source share

A singular form often makes more semantic meaning for class names and table names in databases, because each instance (or row in the database) is a feature.

You can apply the same reasoning to arrays. You might think of package [4] as package number 4, rather than number 4 as a bunch of packages.

IMHO, EventService and PlayerInterface are the best names that sound better for the English ear.

+1
source share

All Articles