Click here to Skip to main content
16,010,427 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: GO HUNGARIAN! Pin
Nemanja Trifunovic1-Feb-05 5:15
Nemanja Trifunovic1-Feb-05 5:15 
GeneralRe: GO HUNGARIAN! Pin
toxcct1-Feb-05 6:15
toxcct1-Feb-05 6:15 
GeneralRe: GO HUNGARIAN! Pin
Ravi Bhavnani2-Feb-05 3:30
professionalRavi Bhavnani2-Feb-05 3:30 
GeneralRe: GO HUNGARIAN! Pin
Alvaro Mendez3-Feb-05 5:42
Alvaro Mendez3-Feb-05 5:42 
GeneralNow this is too far. Pin
Prakash Nadar1-Feb-05 0:24
Prakash Nadar1-Feb-05 0:24 
GeneralRe: Now this is too far. Pin
mlkeS1-Feb-05 15:38
mlkeS1-Feb-05 15:38 
Generalold habits die hard :) Pin
feline_dracoform31-Jan-05 23:58
feline_dracoform31-Jan-05 23:58 
GeneralMix Pascal+Camel Pin
BlackTigerAP31-Jan-05 9:03
BlackTigerAP31-Jan-05 9:03 
GeneralRe: Mix Pascal+Camel Pin
Alexsander Antunes31-Jan-05 23:52
professionalAlexsander Antunes31-Jan-05 23:52 
Generalfunctional names and scope prefix Pin
Jesse Evans31-Jan-05 7:20
Jesse Evans31-Jan-05 7:20 
GeneralRe: functional names and scope prefix Pin
Bamaco231-Jan-05 9:55
Bamaco231-Jan-05 9:55 
Generalhow about "as short as possible" ? Pin
stephen.hazel31-Jan-05 4:57
stephen.hazel31-Jan-05 4:57 
GeneralRe: how about "as short as possible" ? Pin
Nitron31-Jan-05 5:50
Nitron31-Jan-05 5:50 
GeneralRe: how about "as short as possible" ? Pin
stephen.hazel31-Jan-05 6:39
stephen.hazel31-Jan-05 6:39 
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 
GeneralI indicate scope in prefix Pin
Bamaco230-Jan-05 23:46
Bamaco230-Jan-05 23:46 
This way, looking at code, I can't tell the type of a thing, but I can tell
what scope it has.

prefix meaning
"a" attributes
"g" static or global
"k" constant
"p" parameter

ex:

extern const COLORREF kDefaultColor;

struct TPixel {
COLORREF aBackColor;
CPoint aPosition;

void color( COLORREF pColor = kDefaultColor);
COLORREF color() const;

};

Furthermore, I use "C" or "T" to denote a C++ TYPE or a C STRUCT.

On member function accessors, I use "camelCase".
On member function not use for accessors, I use "PascalCase".
On local (stack) variable, I use "c_style_case".

I think that encoding the TYPE of something in a variable name defeats the
purpose of a language with strong type checking emphasis, such as C++.

I find it easyer to encode the scope. At least, it makes it easy to read.
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 

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.