views:

1297

answers:

12

While trying to cleanup an application's API, I found myself scratching my head...

What should I call the variable for a user's name "username", or "userName"?

+48  A: 

I vote for "username" (one word).

"User name" (as two words) could easily mean "The user's real world name", whereas "username" (one word) has a specific meaning in many contexts (an operating system username, for instance).

My name is Richie Hindle, but my username is RichieHindle.

RichieHindle
You're right, i delete my answer, yours is the best =)
Clement Herreman
So do I. http://www.answers.com/username (But there is no such thing as a login - that's the process of logging in.)
Jan Aagaard
Also the most common and, therefor, the most familiar.
T Pops
I wholeheartedly agree. +1
Randolpho
A: 

As a lazy typist, I vote "username"

Corey Trager
laziness in typing is never a good reason while coding
sbi
you type it once, but read it hundreds of times!
DanDan
you should really consider uname instead. It far shorter and more obscure :)
shiva
Ouch. Tough room!
Corey Trager
A: 

I always use userName

Juan Manuel
To me, that's the real name of the user.
Jan Aagaard
@Jan, i use realName for that.
ercu
+1  A: 

I'll vote user_name since no one has voted for it yet. :)

Dusty
COBOL: 'user-name'
tpower
I won't downmod you, but BOOOOOOOOOOOOOOOOOOOOOO!!!
Randolpho
Haha. Thanks. Truthfully in practice I generally use username because of laziness, but I decided to put user_name to offer another perspective because everyone else is posting username. I don't type fast enough to be the first response. :)
Dusty
+2  A: 

FxCop, IIRC, will tell you to call it UserName or userName (depending on context) by default.

So that could be your deciding factor.

Randolpho
+1  A: 

I generally have always used the term in regards to a user login as "Username" (as a variable - "username"). However, if I'm talking about a user's name, then it's "userName".

I think the general convention is to use "username" as one word.

Corazu
A: 

As two words are combined, "user" and "name", for me it is "userName". Also I always use "userName" because FxCop tells me to.

bbohac
+1  A: 

'username' should be the name they log in with. 'userName' should be their actual name.

My username is 'akway' here, while my name is 'Austin Way', for example.

Important Edit: You should not have username and userName anywhere near each other.

akway
A: 

I personally prefer loginName (or, perhaps, userID, although some people might interpret this to be a number) because of the confusion over what a "username" might be.

Jeffrey Kemp
+1  A: 

It depends...

userName - for Windows/Java fanatics.

user_name - for C/UNIX/Linux fans.

user-name - for some old languages and database programmers (Progress, Cobol, ...).

username - for all others.

:)

Thevs
is there space for uname there :)
shiva
uname stands for Unix name - please don't touch it! :)
Thevs
Why is that a problem if you are writing, say, an app in C# or Java or python. further, if one keeps the scope of variables small as possible, it shouldn't matter how big or small the variable name is. In a function with 10-25 lines of code, the argument over naming conventions of variables is simply pedantic, the length however, really contributes to readability.
shiva
The question said that this decision affected a public API. So the ramifications go far beyond "10-25 lines of code."
Richard Berg
+1  A: 

Use username to refer to the unique identifier by which the user is known to the system. If you want to use userName, I say go ahead, so long as you are consistent.

The distinction between this identifier and the user's real life details should not rest on the capitalization of a single letter.

Those variables can be stored in a User class (or equivalent) and should be named to reflect the information they hold. E.g. User.fullname or User.lastname. As before, if you want to call these User.fullName or User.lastName, again, go ahead, but be consistent.

referer anyone? The world did not end when that was misspelled.

Sinan Ünür
A: 

I've always found camel-casing a distraction. I think it is over hyped. What I find really useful is to structure code, such that general boundaries around flow conditions are more visible (eg. all LHS and RHS of an assignment align, contents of if block are of mostly same length lines, etc..) If all other variables are camel-cased, use it for userName as well.

shiva
soyoulikethosereallylongvariablesthatyoucantread
Matthew Whited
v. soYouLikeThoseReallyLongVariablesThatYouCantRead ... you choose
Matthew Whited
one idea will be to not use really long variable names. :) I prefer readable_var vs soyoulikethosereallylongvariablesthatyoucantread
shiva