Click here to Skip to main content
15,913,773 members

Survey Results

Naming conventions in your code   [Edit]

Survey period: 24 Nov 2003 to 30 Nov 2003

What notations do you use when coding?

OptionVotes% 
Hungarian notation with prefixes (strFirstName, m_nNumber etc)76150.13
Hungarian notation without prefixes ( _nNumber etc)432.83
Camel Caps (numberOfDays, isValid etc)46230.43
Pascal case (BackColor, DataSet)17911.79

View optional text answers (92 answers)


 
GeneralRe: Only habits... Pin
John R. Shaw25-Nov-03 10:46
John R. Shaw25-Nov-03 10:46 
GeneralRe: Only habits... Pin
andyj11526-Nov-03 2:05
andyj11526-Nov-03 2:05 
GeneralRe: Only habits... Pin
John R. Shaw27-Nov-03 8:14
John R. Shaw27-Nov-03 8:14 
GeneralHungarian, but a simple version Pin
Anonymous24-Nov-03 1:56
Anonymous24-Nov-03 1:56 
GeneralRe: Hungarian, but a simple version Pin
Anonymous25-Nov-03 9:14
Anonymous25-Nov-03 9:14 
GeneralRadiobuttons not adequate for this question Pin
jhwurmbach24-Nov-03 1:35
jhwurmbach24-Nov-03 1:35 
GeneralThis poll is silly Pin
dog_spawn24-Nov-03 6:45
dog_spawn24-Nov-03 6:45 
GeneralC++ is so rich in types... Pin
Bamaco224-Nov-03 0:43
Bamaco224-Nov-03 0:43 
Wink | ;)
... That I do not want to make the language more poor by adding type informations
to my identifier.

Instead, I like to use simple prefixes:

a for attributes
p for method arguments (parameters)
C for class
k for constants
g for globals (like static class attributes)

For me, having a "num" "str" "hwnd" prefixes defeats the purpose of C++ types

I sometimes use T for typedefs or simple structures.
I always use C for class names

I find code much more easy to read this way - except that I am alone to use these
conventions Confused | :confused:

For local "stack" variables, I use lowercase_underscore_separated identifiers.

When I deal with "complex" expressions, I tend to add a named variable to simplify it.

Sometimes, I disgress by naming local variables in such a way as to repeat it's type.
When I do that, the context usually prooves me right.

...
...
CTracerUtility& tracer = CTracerUtility::Singleton();
...
...

I must confess that my projects (usually huge ones) often contains huge amounts of classes.

I try to write my code with the feeling that even if it is trivial, I must be able to
instantly recognize the intent of the code 6,12 or 18 months later.

Using such a notation helps me a lot. (I write a LOT of code...)
GeneralRe: C++ is so rich in types... Pin
Paul Watson24-Nov-03 5:26
sitebuilderPaul Watson24-Nov-03 5:26 
GeneralRe: C++ is so rich in types... Pin
Bamaco224-Nov-03 9:05
Bamaco224-Nov-03 9:05 
GeneralRe: C++ is so rich in types... Pin
JaniOrca25-Nov-03 1:44
JaniOrca25-Nov-03 1:44 
GeneralDepends Pin
Thomas Freudenberg23-Nov-03 19:54
Thomas Freudenberg23-Nov-03 19:54 
Generalnotation per language Pin
SimonS23-Nov-03 19:05
SimonS23-Nov-03 19:05 
GeneralComments Pin
J. Dunlap23-Nov-03 18:46
J. Dunlap23-Nov-03 18:46 

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.