When I'm programming, I often find myself writing functions that -should- (to be proper english) contain apostrophes (too bad C started everyone thinking that an apostrophe was an appropriate delimiter). For example: get_user's_group() -> get_users_group()
. What do you guys do with that forced-bad-english ambiguous english? Just ignore the apostrophe? Create a different phrasing?
views:
274answers:
12Ingore it, move on!
Although get_user_group()
would work in this care also.
In that case, I would do get_group_for_user()
.
So, yes, I would "create a different phrasing" :)
Either that, or user.get_group()
.
Either get_user_ApostropheShouldBeHereButLanguageWillNotLetMe_s_group
or just ignore it because it really doesn't matter.
Normally I just drop the apostrophe, but do back-ticks work? (get_user`s_group)
I ignore the apostraphe getGroupyUser
and group_from_user
are both perfectly understandable. Worrying about having correct grammer in your function names is a waste of time and distracts from the correct goal of having clear and understandable user names.
getGroupOfUser
? getUserGroup
?
It's a programming language, not literature...
It would be getBackgroundColour
in proper English (rather than getBackgroundColor
)
the point of proper english in function naming is a bit extreme ...
i mean why is the apostrophe bothering you but the _ instead of a space is not ?
Depending on the programming language you may be able to use Unicode variable names, this SO thread lists a few.
With Unicode identifiers you could use one of the unicode apostrophes to give the proper english language formatting to your variable name. Though this only speculative. And it would be hard to maintain. Actually, now that I think about it, it sounds downright evil.
Personally I'd write get_user_group()
rather than get_group_for_user()
since it feels like it reads better to me. Of course, I use a programming language where apostrophes are allowed in names:
proc get_user's_group {id} {#...}
Although, some of the more prolific non-English-native European users use it as a word separator:
proc user'group {id} {#...}
to each his own I guess..
Two points: First, don't use a name that would otherwise require an apostrophe if you can avoid it. Second, you are right in being concerned about ambiguity. For example, you could have:
getUsersGroup
: gets the group of a list of users. If you are using an object-oriented language, this could have more information than just a group ID string. You could also have something likecreateUsersGroup
, which would create a group object from a list of users passed in.getGroupOfUser
: takes in some sort of user object; returns the name of the group of the usergetGroupByUserId
: takes in the user's name or a unique ID associated with that user; returns the name of the group of the user
The best way to delineate the difference between all of these is to just use standard method comments that explain the method names. This would depend on what language you are working with and what style of method comments your organization conventionally uses.