what do you prefere for naming: database - c++ - java - php?

1- User_id - User_Name
2- user_id - user_name
3- UserId - UserName
4- userId - userName
5- else

Personally I prefer camel case, username or multipleWordUsername

However, I code in PHP, and it's convention there to use all lowercase variables, with words separated by underscores, such as username or user_id

Personally I think it's ugly.

ah, I much prefer everything in capitals rather than lowercase if we're going to use underscores between words.
Anyway, it's not USER_NAME but USERNAME, single word.
USERID or USER_ID, your choice.

I like #2
Got used to it writing lots of C code.

I use #4 for private properties and local variables, #3 for public properties, constants, table- and column names.

camelCase makes more sense to me.

Member Avatar

diafol

No.2 for me usually for database items - but username not user_name (as mentioned by jwenting). Each to his or her own though. I use camelCase for other things though.

depends on data type

sUserName -- string
iUserID -- integer

I don't write php or java, just c and c++.

what do you prefere for naming: database - c++ - java - php?

Like they say: "When in Rome, do as Romans do."
To me, it's all about whatever is conventionally used in the project or language in question. None is intrinsically better than another, the only thing that makes one notation superior to another is how accustomed the most-likely readers are to it, that's why they're called "conventions". If I program in my C++ library or in Boost, I follow the STL-style custom (lower-case, underscore-separation for most things, except template arguments (and concepts) in CamelCase), because that is the established custom there (and in most "expert" C++ libraries). If I code in Clang (also C++), which makes abusive use of OOP and is heavily influenced by Java and Objective-C, then I write in that Java-style CamelCaseObject.doSomething(); style.

I tend to prefer the C++ STL style because that's what I'm most used to, that's all. I tend to dislike the Java-style CamelCase notation, but that is mostly because I do a lot of C++, and Java-style notation is usually an indicator of Java-style programming, which, in C++, is a guarantee of very poor code quality. So, that's why it's off-putting to me, because I get a bad feeling about what I'm getting into.

Member Avatar

diafol

I much prefer everything in capitals rather than lowercase

Just a note about that - some SQL GUIs automatically capitalize reserved words, so it's a good "heads-up" when you see a fieldname capitalize automatically if you don't use capitals. But, all fields/tables etc should be backticked - but we get lazy :) Perhaps not the best reason for adopting a convention though.

I agree -- I like to capitalize SQL reserved words and make everything else lower-case or a mixture of upper/lower case. That makes reserved words stand out.