How do you name your variable? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 124

How do you name your variable?

Which naming convention do you prefer most? 1. UPPERCASE 2. lowercase 3. camelCase 4. under_score 5. SentenceCase 6. mIxeDcAsE

26th Mar 2017, 12:50 PM
Wisdom Abioye
Wisdom Abioye - avatar
335 Answers
+ 275
SentenceCase for classes, camelCase for variables, UPPERCASE for constants, lowercase for packages.
26th Mar 2017, 12:53 PM
Tashi N
Tashi N - avatar
+ 58
camelCase if I need to declare alot of variables, lowercase if it is just a small code and mIxeDcAsE if I just woke up early in the morning :F
27th Mar 2017, 7:41 AM
MrCoder - avatar
+ 37
@Dayve You rebel! 😂
26th Mar 2017, 1:00 PM
Tashi N
Tashi N - avatar
+ 32
What if we mix up every convention? stated above!😯😯
26th Mar 2017, 12:58 PM
Dev - avatar
+ 26
As per Google C++ Style Guide (with a few edits here and there) Naming The most important consistency rules are those that govern naming.  Type Names Type names start with a capital letter and have a capital letter for each new word, with no underscores. class UrlTableTester { ... struct Variable Names The names of variables (including function parameters) and data members are all lowercase, with underscores between words. Data members of classes (but not structs) additionally have trailing underscores. a_local_variable a_struct_data_member a_class_data_member_ Common Variable names string table_name; // OK - uses underscore. string tablename; // OK - all lowercase. string tableName; // Bad - mixed case. Constant Names Variables declared constexpr or const, and whose value is fixed for the duration of the program, are named with a leading "k" followed by mixed case. const int kDaysInAWeek = 7; Function Names Regular functions have mixed case; accessors and mutators may be named like variables. Ordinarily, functions should start with a capital letter and have a capital letter for each new word (a.k.a. "Camel Case" or "Pascal case"). Such names should not have underscores. Prefer to capitalize acronyms as single words (i.e. StartRpc(), not StartRPC()). AddTableEntry() DeleteUrl() OpenFileOrDie() Learn more:
3rd Apr 2017, 5:43 PM
Maxim Remyga
Maxim Remyga - avatar
+ 23
lowercase="the simplest"
26th Mar 2017, 2:44 PM
+ 22
I use semantic classnames of camelCase convention
26th Mar 2017, 12:53 PM
Chirag Bhansali
Chirag Bhansali - avatar
+ 21
I prefer 3. camelCase and 4. under_score
3rd Apr 2017, 3:32 PM
Naeem Rind
Naeem Rind - avatar
+ 19
I use all except lowercase and SentenceCase.
26th Mar 2017, 1:36 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 19
I name the variables like this - camel_Case which involves everything one uppercase, lowercases, and an underscore But it's up to the programmer how he names the vars according to his convenience
3rd Apr 2017, 3:11 PM
Siddharth Saraf
+ 18
1 Letter at a time
3rd Apr 2017, 3:12 PM
Seth T
Seth T - avatar
+ 18
It's always better to follow the standards UPPERCASE --> CONSTANTS lowercase --> packages or libraries camelCase --> functions or methods SentenceCase --> Classes under_score --> variables or pointers (very rare) miXeDcaSe --> I never tried this 😉
3rd Apr 2017, 6:10 PM
Santosh Pothina
Santosh Pothina - avatar
+ 17
Thx to every single one of you for liking my answer. You gave the 'popular answer' badge to me 😘 Special thx to Tamra who was the hundredth upvoter!
3rd Apr 2017, 8:50 PM
Tashi N
Tashi N - avatar
+ 15
lowercase and UPPERCASE
3rd Apr 2017, 3:22 PM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
+ 15
I usually name variables in lowercase until I name it using two words. When I use two words as variable's name, I use camelCase as it is easy to read for everyone. If you want to write variable name in lower case using two words, use an underscore sign (_).
3rd Apr 2017, 3:32 PM
Biraj Patel
+ 14
3rd Apr 2017, 3:09 PM
Aflah Benrostom
Aflah Benrostom - avatar
+ 14
camelCase is easier to write and read.
3rd Apr 2017, 3:32 PM
Atallabela Yosua
+ 14
camelCase and lowercase
3rd Apr 2017, 5:09 PM
+ 13
I usually use SentenceCase
28th Mar 2017, 3:14 AM
LiterallyJessika - avatar
+ 13
simply its better, I think, to name your variable in lower case and constants in upper. it will create a simple distinction and will be easy to maintain the code.
3rd Apr 2017, 3:08 PM
Zainul Abedin
Zainul Abedin - avatar