Click here to Skip to main content
15,904,156 members

Survey Results

Naming conventions in your code   [Edit]

Survey period: 31 Jan 2005 to 6 Feb 2005

What notations do you use when naming variables? (And have things changed since we first asked back in 2003?)

OptionVotes% 
Hungarian notation with prefixes (strFirstName, m_nNumber etc)77140.86
Hungarian notation without prefixes ( _nNumber etc)492.60
Camel Caps (numberOfDays, isValid etc)72538.42
Pascal case (BackColor, DataSet)22511.92
C-style (this_is_a_variable)492.60
FORTRAN case (all caps)30.16

View optional text answers (82 answers)


 
GeneralRe: how about "as short as possible" ? Pin
Nitron31-Jan-05 8:06
Nitron31-Jan-05 8:06 
GeneralRe: how about "as short as possible" ? Pin
stephen.hazel31-Jan-05 8:47
stephen.hazel31-Jan-05 8:47 
GeneralRe: how about "as short as possible" ? Pin
toxcct1-Feb-05 6:18
toxcct1-Feb-05 6:18 
GeneralKind of a hard question Pin
hannahb31-Jan-05 3:34
hannahb31-Jan-05 3:34 
GeneralDepends on the library default Pin
ed welch31-Jan-05 2:01
ed welch31-Jan-05 2:01 
GeneralRe: Depends on the library default Pin
Nemanja Trifunovic1-Feb-05 4:31
Nemanja Trifunovic1-Feb-05 4:31 
GeneralPascal with humps Pin
Gary R. Wheeler31-Jan-05 0:46
Gary R. Wheeler31-Jan-05 0:46 
GeneralMix of Hungarian and Camel Caps Pin
Antti Keskinen31-Jan-05 0:01
Antti Keskinen31-Jan-05 0:01 
I use somewhat of a mix of Hungarian notation and Camel Caps.

For example, all object and reference variables start with a prefix obj or ref. Pointers are p. Global variables have a prefix g_. For standard variables, 'n' is integer, 's' is short, 'c' is char, 'l' is long, 'f' is float and 'd' is double. For pointer-to-value types, only the pointer prefix is used, aka the type of pointed-to is not visible in the declaration.

I've fathomed a small syntax for my variables

expr:
[g_][type][name in Camel Caps]

The problem is that if I have a type double, like in g_dMaxSum, and I need to change it to float, it's always a find & replace run.

I use this for all languages I use. It might be difficult to read, and problematic in change situations, but I like it Blush | :O

-Antti Keskinen

----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"

-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
GeneralI indicate scope in prefix Pin
Bamaco230-Jan-05 23:46
Bamaco230-Jan-05 23:46 
GeneralAssuming local variables... Pin
Colin Angus Mackay30-Jan-05 22:58
Colin Angus Mackay30-Jan-05 22:58 
GeneralDepends on the language Pin
Michael P Butler30-Jan-05 21:56
Michael P Butler30-Jan-05 21:56 
GeneralRe: Depends on the language Pin
Brian Delahunty30-Jan-05 22:21
Brian Delahunty30-Jan-05 22:21 
GeneralRe: Depends on the language Pin
Gary R. Wheeler31-Jan-05 0:48
Gary R. Wheeler31-Jan-05 0:48 
Generalas always... CListCtrl Pin
Aqualic30-Jan-05 20:49
Aqualic30-Jan-05 20:49 
GeneralRe: as always... CListCtrl Pin
Uwe Keim2-Feb-05 23:27
sitebuilderUwe Keim2-Feb-05 23:27 
GeneralA bit of an alteration... Pin
Ray Cassick30-Jan-05 18:39
Ray Cassick30-Jan-05 18:39 
GeneralSome time i create my Own Pin
ThatsAlok30-Jan-05 21:47
ThatsAlok30-Jan-05 21:47 
GeneralRe: Some time i create my Own Pin
Blake Miller31-Jan-05 7:45
Blake Miller31-Jan-05 7:45 
GeneralRe: Some time i create my Own Pin
feline_dracoform31-Jan-05 23:42
feline_dracoform31-Jan-05 23:42 
GeneralRe: Some time i create my Own Pin
James R. Twine2-Feb-05 6:09
James R. Twine2-Feb-05 6:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.