Click here to Skip to main content
15,914,225 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 
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 
Hungarian notation is a useful tool - when working in environments that do not enforce type checking (such as scripting languages, etc). Using a prefix can clue you in to what you expect the variable to contain.

In type enforced languages - the compiler will note when you have a type error. It's pretty easy to fix these little bugs so the type notation isn't needed. Also, variable scope should be small enough that it is easy to refer to the declaration, if needed.

However, Hungarian notation has a dark side - and that is that it flies right into the face of encapsulation and data hiding. Of course, there is the contradiction that C++ programmers are the most likely to be the ones using Hungarian notation. Variables should be named for what they represent and not by how they are implemented!

It's also a maintenance issue. In later revisions, a variable could be switched to a different type (that conforms to the semantics of the original type used) - only the declaration and constructor calls would need modification. If Hungarian notation was used - you would have to track down all of the now erroneous prefixes and change them.

I'm really glad that the next generation of programmers won't be seeing the apparent endorsement of this technique in books (at least for .NET).

Dale Thompson

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.