share
Stack OverflowIs "username" one word or two?
[+29] [13] JaredCacurak
[2009-07-22 15:37:30]
[ language-agnostic naming-conventions ]
[ http://stackoverflow.com/questions/1166164/is-username-one-word-or-two ] [DELETED]

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"?

(15) I have the same doubt for filename vs. fileName - Federico Ramponi
(2) Why does it matter how you spell it in the API so long as you are consistent? - Sinan Ünür
This is the best question I have seen all week! - Troggy
[+61] [2009-07-22 15:38:18] RichieHindle [ACCEPTED]

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.


(1) You're right, i delete my answer, yours is the best =) - Clement Herreman
(2) So do I. 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. - Travis
I wholeheartedly agree. +1 - Randolpho
1
[+3] [2009-07-22 15:58:36] Thevs

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.

:)


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
2
[+2] [2009-07-22 15:40:44] Randolpho

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

So that could be your deciding factor.


3
[+2] [2009-07-22 15:43:09] akway

'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.


4
[+2] [2009-07-22 16:06:43] Sinan Ünür

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 [1] anyone? The world did not end when that was misspelled.

[1] http://en.wikipedia.org/wiki/HTTP%5Freferrer

5
[+1] [2009-07-22 15:39:23] Dusty

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


COBOL: 'user-name' - tpower
(2) 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
6
[+1] [2009-07-22 15:41:53] Corazu

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.


7
[0] [2009-07-22 15:38:56] Corey Trager

As a lazy typist, I vote "username"


(1) laziness in typing is never a good reason while coding - sbi
(2) you type it once, but read it hundreds of times! - DanDan
(2) you should really consider uname instead. It far shorter and more obscure :) - shiva
Ouch. Tough room! - Corey Trager
8
[0] [2009-07-22 15:38:58] JQAn

I always use userName


(1) To me, that's the real name of the user. - Jan Aagaard
(1) @Jan, i use realName for that. - ercu
9
[0] [2009-07-22 15:42:09] bbohac

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


10
[0] [2009-07-22 15:44:37] Jeffrey Kemp

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.


11
[0] [2009-07-22 16:30:02] shiva

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.


(1) soyoulikethosereallylongvariablesthatyoucantread - Matthew Whited
(3) v. soYouLikeThoseReallyLongVariablesThatYouCantRead ... you choose - Matthew Whited
one idea will be to not use really long variable names. :) I prefer readable_var vs soyoulikethosereallylongvariablesthatyoucantread - shiva
12
[0] [2012-04-21 00:18:24] ClarityForce

"username" is a one word according to dictionary.
However, according to the following MSDN article:
http://msdn.microsoft.com/en-us/library/ms229043.aspx
it should be declared as "userName" (or "UserName") because it's not a "closed-form compound word".


13