0
Anyone else finds naming things in programming quite difficult?
I often find it quite difficult to come up with good names for variables, methods, etc. For instance, what should a method be called that get the user based on id: GetUser(string id), GetUserById(string id), GetUserFromId(string id) etc. ? Another example could be a variable that stores a collection of users. Should it be called users, userList, listOfUsers, userCollection etc? Sometimes I find myself spending quite some time finding the "best" name.
1 Answer
0
It is tricky, yes. Do not reinvent the wheel.
Use your own naming convention and use it every time.
Then you only have to think once and use it.
So choosse 1 of your 4 option, and stick with it.
If it is a collection I prefer to use List or Collection in the name.
Variables always contain a noun
Methods always contain a verb and most of the time also a noun