How do you name your variable? | SoloLearn: Learn to code for FREE!


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

3/26/2017 12:50:16 PM

Wisdom Abioye

336 Answers

New Answer


SentenceCase for classes, camelCase for variables, UPPERCASE for constants, lowercase for packages.


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


@Dayve You rebel! 😂


What if we mix up every convention? stated above!😯😯


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:


lowercase="the simplest"


I use semantic classnames of camelCase convention


I prefer 3. camelCase and 4. under_score


I use all except lowercase and SentenceCase.


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


1 Letter at a time


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 😉


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!


lowercase and UPPERCASE


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 (_).




camelCase is easier to write and read.


camelCase and lowercase


I usually use SentenceCase


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.