Click here to Skip to main content
15,899,474 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)


 
GeneralProject and language/library consistency Pin
Mike Dimmick5-Feb-05 6:02
Mike Dimmick5-Feb-05 6:02 
GeneralDepends on what i'm doing. Pin
Shog94-Feb-05 13:03
sitebuilderShog94-Feb-05 13:03 
I hate reading hungarian, so when doing a little one-shot program i'll generally not use it. But on something that will be collaborated on/maintained by others, i'll use it to a point, simply because it's our agreed-upon standard.

Interestingly, i have no problem with type prefixing for simple types - p == pointer, str == string, n == int etc. are all easy enough for me to read, provided the writer was consistent (this is also as far as i'll go when writing). But a lot of hungarian code goes much further than this (perhaps it is "correct", i've never seen full docs on hungarian, so can't say). When you get to the point where Intellisense becomes useless as you can't remember all the meta information encoded in front of the variable name, you've shot yourself in the foot - you can't recall the name manually and your tools are useless.

A more insidious problem lies in the false sense of confidence type prefixing can give you when reading someone else's (badly written/maintained) code. I couldn't count the number of times i've run across code passing string pointers in place of BOOLs, or ints in place of doubles... Compiling with a good warning level helps, as does upgrading to the latest versions of VC++ (decent type-checking rocks!). But in the end, people make mistakes, and you can never trust the veracity of a naming scheme when you didn't write the code yourself (if even then...).

Shog9

I'm not the Jack of Diamonds... I'm not the six of spades.
I don't know what you thought; I'm not your astronaut...

GeneralMixing Stuff Pin
Alejandro K.4-Feb-05 1:53
Alejandro K.4-Feb-05 1:53 
GeneralRe: Mixing Stuff Pin
Paranoicus Maximus6-Feb-05 17:21
Paranoicus Maximus6-Feb-05 17:21 
GeneralGood poll! Pin
thwart3-Feb-05 4:07
thwart3-Feb-05 4:07 
GeneralRe: Good poll! Pin
gehkadl3-Feb-05 6:22
gehkadl3-Feb-05 6:22 
GeneralRe: Good poll! Pin
Michael Dunn3-Feb-05 7:50
sitebuilderMichael Dunn3-Feb-05 7:50 
GeneralRe: Good poll! Pin
gehkadl3-Feb-05 21:07
gehkadl3-Feb-05 21:07 
GeneralRe: Good poll! Pin
Ravi Bhavnani5-Feb-05 9:29
professionalRavi Bhavnani5-Feb-05 9:29 
GeneralThis should be multiply selection poll Pin
Igor Urdenko2-Feb-05 21:20
Igor Urdenko2-Feb-05 21:20 
GeneralDitto Pin
Grimolfr3-Feb-05 4:30
Grimolfr3-Feb-05 4:30 
GeneralRe: Ditto Pin
malharone3-Feb-05 6:30
malharone3-Feb-05 6:30 
GeneralRe: Ditto Pin
Grimolfr3-Feb-05 8:28
Grimolfr3-Feb-05 8:28 
GeneralEspanol? Pin
Michael Dunn2-Feb-05 13:45
sitebuilderMichael Dunn2-Feb-05 13:45 
GeneralRe: Espanol? Pin
Alvaro Mendez3-Feb-05 6:01
Alvaro Mendez3-Feb-05 6:01 
GeneralDepends on platform Pin
Madhu Kampurath1-Feb-05 17:52
Madhu Kampurath1-Feb-05 17:52 
GeneralRe: Depends on platform Pin
Ravi Bhavnani2-Feb-05 3:27
professionalRavi Bhavnani2-Feb-05 3:27 
GeneralRe: Depends on platform Pin
Anonymous2-Feb-05 4:57
Anonymous2-Feb-05 4:57 
GeneralcamelCase vs Hungarian Pin
Phil Sidari1-Feb-05 10:07
Phil Sidari1-Feb-05 10:07 
GeneralRe: camelCase vs Hungarian Pin
Jörgen Sigvardsson1-Feb-05 11:14
Jörgen Sigvardsson1-Feb-05 11:14 
GeneralRe: camelCase vs Hungarian Pin
mlkeS1-Feb-05 15:37
mlkeS1-Feb-05 15:37 
GeneralRe: camelCase vs Hungarian Pin
slimtim1-Feb-05 20:00
slimtim1-Feb-05 20:00 
GeneralRe: camelCase vs Hungarian Pin
James R. Twine2-Feb-05 6:03
James R. Twine2-Feb-05 6:03 
GeneralRe: camelCase vs Hungarian Pin
slimtim2-Feb-05 9:10
slimtim2-Feb-05 9:10 
GeneralRe: camelCase vs Hungarian Pin
Dale Thompson2-Feb-05 12:34
Dale Thompson2-Feb-05 12:34 

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.