Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

It is always difficult for me to choose between singular and plural forms for classes names:

CustomerRepository vs. CustomersRepository
CustomerService vs. CustomersService
CustomerController vs. CustomersController

And for composite names it is even more difficult:

OrderCustomerRepository vs. OrderCustomersRepository vs. OrdersCustomersRepository

What approach do you prefer and why?

share|improve this question

closed as primarily opinion-based by Thomas Owens Jul 10 at 9:48

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.

Would the class contain a repository for multiple customers? If it's one repository for one customer... – JeffO Aug 25 '11 at 21:36
@Jeff O, repository can contain GetCustomerById and GetCustomers methods at the same time – Idsa Aug 25 '11 at 21:37
In Data Modeling, a table name should be singular. If your application is using domain classes that correspond 1-1 to your data model then it may be a good idea to keep the naming singular. Of course mapping classes to tables in 1-1 fashion may not be the best way to build your object model for an OO application, but this is beside the question. – NoChance Aug 25 '11 at 23:26

4 Answers 4

up vote 46 down vote accepted

The only thing I pluralize is collections.

foreach (var customer in customers)
    // do something with customer

All of your examples are individual objects, so they are not pluralized. Yes, the names refer to objects that might have multiple instances, but all you need to know in the name is the object entity (i.e. customer).

So in all of your examples, the singular is the correct form. Makes life much easier.

share|improve this answer
I'd use customerCollection for collections, but for the rest of it I agree. This is a best-practice in database design and works quite good in code also. – Jan_V Aug 28 '11 at 12:24
I dislike words like "Collection" here. English has a perfectly good way of referring to a collection of things, using plurals. – Steven Burnap May 13 '12 at 3:26

Use singular. The tool to turn screws with is called "screw driver" not "screws driver".

However, pluralize your method and property names accordingly, to indicate whether one value or a collection of them will be returned.

share|improve this answer

Definitely singular. You don't create an object of People, you create a collection of Person objects. The only time I would use plurals would be for static classes, i.e. SupportServices, StringUtils, etc. However in this case, the class acts more as a namespace than anything else.

share|improve this answer
And to think, all this time I've been using Peoples collections! – Jordan Aug 26 '11 at 5:18
List<person> people ... seems ok to me, @Jordan. – StevenV Aug 28 '11 at 14:37

Remember, a class is a template for an object. So think about the object that you are referring to.

Often it is a singular entity, especially when it is an ORM entity. Sometimes it could be a collection.

I believe the answer is specific to the context.

share|improve this answer

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