Skip to main content
gamedev.net
🔒 Locked

What notation do you use?

Started by elendil67 48 replies 1k views
Original Post
elendil67
elendil67
I think I saw a poll on this before at GDNet, but I can''t find it. So what do you use?
  • m_pHungarianNotation
  • camelBack
  • old_school_unix_c
  • cc (carmack code)
  • eLeEt SkRiPt KiDdIe
When you go homeTell them of us, and say:For your tomorrow,We gave our today.
Erunama
Erunama
I normally use camelBack, thought every once in a while I''ll use Hungarian, but only for a select class or two. And normally without the data type description (like b for bool). The only thing Hungarian really does for me is make it easier to see which variables are member functions of the class (m_position, for instance).

|.dev-c++.|.the gimp.|.seti@home.|.dbpoweramp.|.torn.|.=w=.|
Tron3k
Tron3k
I''m guessing Carmack code is just completely illegible code That''s sort of like me sometimes. I use the m_ prefix for class members. I also use g_ for globals.

Firebird Entertainment
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
Waverider
Waverider
I use m_ for members and g_ for globals, too.

I precede long pointers with lp as well. m_lpChild, for example.

Also, for my own convenience, if a pointer is a reference to an existing memory block but was not used to allocate it, I put Ref on the end so I don't try to delete it within the class's destructor. (m_lpTargetRef)

I usually fail to put i, l, dw, f, etc. in front of ints, longs, double words and floats. That's a practice I'll have to improve on.


[edited by - Waverider on March 3, 2003 6:51:38 PM]
It's not what you're taught, it's what you learn.
Cold_Steel
Cold_Steel
I use camelBack most of the time. I occaisonally prefix things if it makes it easier to understand.

I always use p in front of pointers. e.g. pPointer

I use s in front of strings if it isn''t clear it''s a string, like sTemp, but not fileName.

I almost never prefix integers of floats or any numerical things. I generally do prefix classes with a c, like cModel.
______"Man is born free, and everywhere he is in chains" - J.J. Rousseau
owl
owl
quote:
Original post by Waverider
I use m_ for members and g_ for globals, too.

I precede long pointers with lp as well. m_lpChild, for example.

Also, for my own convenience, if a pointer is a reference to an existing memory block but was not used to allocate it, I put Ref on the end so I don't try to delete it within the class's destructor. (m_lpTargetRef)

I usually fail to put i, l, dw, f, etc. in front of ints, longs, double words and floats. That's a practice I'll have to improve on.


This works great for me too. I find really usefull to have al my member variables preceded by m_ so I can name the parameters on my methods with the same name as the member variable when required (ie: m_iPosX = iPosX; ). Writing the initial of the data type is also good when you have lotta varibles and you dont want to memorize the type of every variable.



[edited by - xaxa on March 3, 2003 6:58:09 PM]
[size="2"]I like the Walrus best.
Waverider
Waverider
Oh, I also put p_ in front of parameter names, so that I know in a large function which variables are parameters, and which are members, globals and locals.

If the variable has no m_, g_ or p_, I know it''s a variable local to the function.
It's not what you're taught, it's what you learn.
owl
owl
quote:
Original post by Waverider
Oh, I also put p_ in front of parameter names, so that I know in a large function which variables are parameters, and which are members, globals and locals.

If the variable has no m_, g_ or p_, I know it''s a variable local to the function.


you could easily misread and think the parameter is a pointer. And pointer parameters will look like p_piXpos, weeee

[size="2"]I like the Walrus best.
CWizard
CWizard
I must be what you call a "old_school_unix_c" guy. For variables at least. For functions and (non-"atomic") classes/structs/types I use the Hungarian variant (ie. SomeFunction()). For "atomic" classes I use STL-like naming.

I tried at some point to use Hungarian for variables, but it fails, and without thinking of it I started to move to "old_school_unix_c" notation, it seems so much more natural, and never fails.

camelBack, I cannot stand; it''s just soo damn ugly. Who is Carmack?

Shall I go get the flame thrower now?


Tron3k
Tron3k
The irony is that your nickname is "CWizard."

BTW, John Carmack is the guy who made iD games like Doom and Quake.

Firebird Entertainment
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
wild_pointer
wild_pointer
I use old_school_unix_c, it seems the most natural to me. It works best with stl and looks like crap for Win32, OpenGL, etc.
[size=2]
Programmer One
Programmer One
A mixture of Hungarian Notation, Camel Back and old_school_unix_c
CWizard
CWizard
quote:
Original post by Tron3k
The irony is that your nickname is "CWizard."
Yeah, that's originally my age old handle CodeWizard. "cWizard" would be worse

EDIT: Oh, just for the record, I do know who Carmack is.




[edited by - CWizard on March 3, 2003 8:13:35 PM]
Sneftel
Sneftel
I use 31337 notation. It really gives your programming style so much more flexibility to have declarations like:

int w0ot( int wO0t, int w0Ot)
{
int wo0t = w0Ot % wO0t;
if(wo0t != 0) return w0ot(wo0t, wO0t);
return wO0t;
}



But... but that''s what HITLER would say!!
elendil67
elendil67
quote:
Original post by Sneftel
I use 31337 notation. It really gives your programming style so much more flexibility to have declarations like:

int w0ot( int wO0t, int w0Ot)
{
int wo0t = w0Ot % wO0t;
if(wo0t != 0) return w0ot(wo0t, wO0t);
return wO0t;
}



But... but that''s what HITLER would say!!


When I write my book on beginning programming, I think I''ll use eleet notation. I see that it is very flexible, and better yet, easy to understand.

I mainly use a smorgasboard of notations. I generally use old_school_unix_c for variable names, and everything else in that sub-Hungarian notation that you guys seem to do. I''m trying to completely switch over to old_school_unix_c or camelBack though.

When you go homeTell them of us, and say:For your tomorrow,We gave our today.
Colin Jeanne
Colin Jeanne
None of the above!

For me, variables are usually lowercase and functions are usually of the form SomeFunction(). Classes and class members usually follow the naming of functions.



Qui fut tout, et qui ne fut rien
Invader''s Realm
Ra
Ra
For assembly, always old_school_unix.
For C, usually old_school_unix, with prefixes and suffixes like timer_int, hd_int, kstart, kmain. (prefixes don''t have the _)



[ Enter the Unspoken Realm ]
Ra
Big B
Big B
Mostly camelBack with some entirely lowercase thrown in there. Occasionally I will prefix ints with "num" like "numIterations" because I immediately read it as "number of Iterations". Strings will get the occasional prefix or postfix of "str" for the same reason.
mikael_j
mikael_j
old_school_unix_c for asm
camelBack for everything else (C,C++,PHP,etc..)

/Mikael
Andrew Russell
Andrew Russell
I use my own notation

CClassesAreLikeThis

FunctionsAreLikeThis();

For member variables (and globals, which I don''t use) I use

m_iHungarianNotation

when I can be bothered, but often fall back to

alllowercase

which is a bit flawed, because I also use alllowercase for parameters.


I have also found a few instances where my type has been so long (and written out in full), that my variable name looks like m_camelBack (yes, with the m_ tagged on the front), and I just hate camelBack.


Btw, I really like the idea of tagging "Ref" on the end of a pointer to something that is not to be deleted using that pointer.

Do not meddle in the affairs of moderators, for they are subtle and quick to anger.


ANDREW RUSSELL STUDIOS
Cool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA | LiT | H*R ]
Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Reference | OGL v D3D | File Formats | Asking Questions | Go FAQ yourself ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.