Click here to Skip to main content
15,899,679 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 
slimtim wrote:
[...] Microsoft employees and contractors there is that they are going away from Hungarian because of inconsistent use (sMyVar or strMyVar for strings, iMyVar or nMyVar for ints)

   Sounds like lack of a consistently applied coding standard and/or guidelines to me.  If you have to ask what it means, then it is not consistent or a standard by any means.  Inconsistent use is usually not a problem with the standard itself, but with the development staff.

   FWIW, my standard uses characters to modify a type, same as when you would declare it, which eliminates some ambigious prefixes, like u.  Also, we do not use a prefix to indicate purpose.  For example:
<br />
    int  iSomeVar = 0;<br />
    short int siSomeOtherVar = 0;<br />
    unsigned int uiStillSomeOtherVar = 0;<br />
    DWORD dwValue = 0;<br />
    DWORD *dwpAPointer = NULL;<br />

   And not:
<br />
    unsigned int uSomeVar = 0;<br />
    short int sSomeOtherVar = 0;<br />
    DWORD cbBufByteLen = 0;     // cb == Count Of Bytes<br />

   Strings are prefixed with s unless we are using multiple kinds of string objects, like when using both CString and std::string for some reason:
<br />
    CString sAString;<br />
    //<br />
    // Or When Using Multiple Kinds...<br />
    //<br />
    CString csACString;<br />
    std::string ssAnSTLString;<br />

   I could not use Intellisense as an excuse for removing documentation, or not providing documentation, which, IMHO, is what you are doing by removing prefixes.  Not everyone that is going to use your code is going to have Intellisense (or something like it).

   Peace!

-=- James
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
DeleteFXPFiles & CheckFavorites

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.