Page 1 of 1

Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 1:08 pm
by Chris
I did an internship a while back at a software company that specializes in Microsoft XRM.

While I was there a colleague of mine taught me to only ever talk in singular form, the reason being that at the end of the day one piece of data will always be in its own right unique.

When I program, I have a tendency to stick to the rule he taught me, and I have to admit it definitely makes perfect logical sense. What I personally hate is people pluralizing the name of a function or variable.

So here's the main goal:
  • It's not the "users" table, it's the "user" table, why?
    • The row data will always equal one user, so call the table "user". It is the user structure.
    • When you want to relate to the table, "users_id" won't make sense unless you meant "user's_id" or "id_of_user", it should be "user_id"
    • Why call it the users object? It's the user object.
  • It's not the "getUsers()" function, it's the "getUserList()" function. Why?
    • It's not the Users object, it's the User object, you want a list of them.
    • A list is a singular form of data containing more singular forms of data.
    • Pluralizing the name of the forms of data restricts the amount of variability of the word list. It's the form of data that is variable, not a list.
  • It's not $users, it's $userList. Why?
    • The object is not called Users, it's the User object, and you are storing more than one of them.
    • It's not the $buckets, it's the $bucketList.
What is your opinion list on this? :D

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 2:11 pm
by Sim
I think I follow that. Now, does that same rule follow for naming of database tables, you think?

For example: you could have a "user" table, but if it had a prefix , wouldn't it be "game_users" ?

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 2:15 pm
by Chris
No, it would be "game_user", unless you mean "user_of_game" or "game's_user" (which is not possible), if you are making a many to many relationship with that table, it will be "game_has_user".

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 2:23 pm
by Sim
Seems right. I got a fix of table names, but for my field names, they seem good.

For example: I got 'game_users' for table name then fields like "userID' , userHandle, not usersID, usersHandle.

Makes sense like your saying. Its just proper English.

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 2:34 pm
by Chris
What database are you using Sim?

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 3:41 pm
by Jackolantern
I mostly tend to follow that, except in a few places where it is .NET convention to pluralize, such as with database contexts and Entity Framework Code First object collections. For example, sometimes you have:

Code: Select all

public List<Employee> Employees;
But that is because it is actually a collection of Employees.

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 3:45 pm
by Sim
Chris wrote:What database are you using Sim?

Custom one.

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 4:27 pm
by Chris
Jackolantern wrote:I mostly tend to follow that, except in a few places where it is .NET convention to pluralize, such as with database contexts and Entity Framework Code First object collections. For example, sometimes you have:

Code: Select all

public List<Employee> Employees;
But that is because it is actually a collection of Employees.
I was taught to call the variable in this case EmployeeList:

Code: Select all

public List<Employee> EmployeeList;
Sim wrote:
Chris wrote:What database are you using Sim?

Custom one.
Maybe I should have been more specific :P, what RDBMS are you using?

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 5:06 pm
by Jackolantern
Chris wrote:I was taught to call the variable in this case EmployeeList:

Code: Select all

public List<Employee> EmployeeList;
You could, but then you are going against Microsoft best practice.

Re: Singular or plural? That is the question.

Posted: Wed Aug 13, 2014 7:52 pm
by Verahta
Hmm, seems there is a conundrum here! One guy says Microsoft says Employees and the other says Microsoft says EmployeeList... Thus, only fair and balanced way to solve this is for Jack and Chris to cage fight in the Thunderdome. 8-)

Image