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

+123

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

+272

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

+56

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

+36

@Dayve You rebel! 😂

+31

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

+25

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: https://google.github.io/styleguide/cppguide.html#General_Naming_Rules

+22

lowercase="the simplest"

+21

I use semantic classnames of camelCase convention

+20

I prefer 3. camelCase and 4. under_score

+18

I use all except lowercase and SentenceCase.

+18

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

+17

1 Letter at a time

+17

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 😉

+16

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!

+14

lowercase and UPPERCASE

+14

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

+13

sentenceCase.

+13

camelCase is easier to write and read.

+13

camelCase and lowercase

+12

I usually use SentenceCase

+12

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.