View Poll Results: What do you prepend your class names with?
- Voters
- 71. You may not vote on this poll
-
A "C" because everyone else does it
-
A "C" because Microsoft does it
-
A "C" because it denotes "class"
-
A "C" -- doesn't this have to do with something to do with hungarian notation or something like it?
-
A "C" for my own reasons
-
A "T" like Borland used to do
-
Something else
-
Nothing -- my class names are clearer without a leading letter.
-
"There's no place like home. There's no place like home. There's no place like home."
-
A "C" because VC6's MFC class wizard adds it for me
-
September 26th, 2004, 10:39 AM
#61
Re: What do you prepend your class names with?
Since when has this discussion been about ADO ?
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
September 27th, 2004, 01:44 AM
#62
Re: What do you prepend your class names with?
 Originally Posted by TheCPUWizard
Since when has this discussion been about ADO  ?
ado n. = bustle; fuss; trouble; bother.
Find more about Much Ado About Nothing.
Last edited by ovidiucucu; September 27th, 2004 at 01:55 AM.
-
September 27th, 2004, 06:32 AM
#63
Re: What do you prepend your class names with?
My comment was a PUN.
I am well familiar with Shakespeares work. This past summer I attended productions of Mid-Winter's Tale (Hartford, Connecticut), Much Ado about Nothing (Boston, Massachusetts) and The Tempest (Sayville, New York).
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
September 27th, 2004, 06:45 AM
#64
Re: What do you prepend your class names with?
 Originally Posted by TheCPUWizard
My comment was a PUN.
Well...
-
September 27th, 2004, 10:01 AM
#65
Re: What do you prepend your class names with?
 Originally Posted by TheCPUWizard
My comment was a PUN.
Did You mean a Physical Unit Number?
Best regards,
Igor
-
September 27th, 2004, 10:37 AM
#66
Re: What do you prepend your class names with?
Hey guys, don't pollute the thread with out-of-topic chat.
-
September 29th, 2004, 09:44 AM
#67
Re: What do you prepend your class names with?
I'm surprised how many people think the "C" has to do with hungarian notation.
Kevin Hall
-
September 29th, 2004, 10:28 AM
#68
Re: What do you prepend your class names with?
I do not embed type information into any names I use.
Naming things well is one of the most important responsibilities and often one of the most difficult challenges facing software developers. Naming is important to correctly understand the problem being solved as well as the solution presented. The names need to be as close to natural language as possible, and at the same time being both concise and precise. I've fixed many bugs (one yesterday) that came about due to poor naming that resulted in a difficulty understanding the problem correctly.
Embedding names with type information does not add anything. I've never been confused as to whether something is a class or an enum or something else. That problem has never ever come up for me. Embedding type information does, however, take away from understanding because you've now taken another step away from natural language. One of the goals of a high-level programming language like C++ is to be closer to natural language.
One convention I do use is prepending (I don't care if it's a word or not!) all my class members with "m_". It is nearly always important to be able to distinguish between local variables and class variables when examining a piece of code. It is rarely important to be able to distinguish between a bool, and enum, and a const pointer to string.
Jeff
-
September 30th, 2004, 08:29 AM
#69
Re: What do you prepend your class names with?
 Originally Posted by TheCPUWizard
I am well familiar with Shakespeares work.
To prepend, or not prepend: that is the question...
-
September 30th, 2004, 10:01 AM
#70
Re: What do you prepend your class names with?
 Originally Posted by jfaust
It is rarely important to be able to distinguish between a bool, and enum, and a const pointer to string.
Lucky you. Imagine you receive 300 MB of source code and you have to examine it. I can guarantee you'll want to spend as little time as possible in browsing the files to learn if code is an int, a bool a string or some user type.
Har Har
-
September 30th, 2004, 10:33 AM
#71
Re: What do you prepend your class names with?
 Originally Posted by PadexArt
Lucky you. Imagine you receive 300 MB of source code and you have to examine it. I can guarantee you'll want to spend as little time as possible in browsing the files to learn if code is an int, a bool a string or some user type.
A well named variable can make it obvious: numCols, itemCount, deltaX, itemName, etc. Enforcing hungarian notation on these is not only silly, it's detremental because it inhibits understanding.
After that, the usage often makes it obvious. If you access through a '->' or a '.', it's a class or a struct. If you concat it with words it's typically a string. If you use it in a mathematical expression, it's typically a numeric type.
In the cases where the usage of a variable or the variable name itself doesn't make it blazingly obvious what type it is, it typically doesn't and shouldn't matter.
I don't care what data type it is. The intent is clear. What do I care is it's an empty string, a 0 int, a null pointer or a class that has a cast to bool operator. We are checking for validity.
When you need to go more in depth and you are debugging or changing code, variables will either be declared locally (the more locally the better) or in the class header. If you are making changes, you should be intimately familiar with the area you are changing. The familiarity should go way beyond what type of data it is. You should understand the meaning and the intent.
Jeff
-
October 1st, 2004, 03:41 AM
#72
Re: What do you prepend your class names with?
I have really no idea why this thread is lasts. People are different. Period.
Each one programmer at the every moment is under the pressure - the pressure of its habits, adopted (willingly or not so) rules, superstitions or explicit orders. Somebody likes to talk about WHY AM I USED TO DO <..> and another one just goes on and tries to do his best. It proves just the only thing: people are different.
BTW: reading the thoughts of yours I did get not a single reason why should I have to betray my own style (whichever it could be). Except the one case - I should obey the company standard (whichever it could be). There's really worthy reason for such exception - they pay me for my job. When fortunately I participate in creation of standard I equip it with the elements (more or less) of my own style without any doubts - when the community approves and adopts them.
"Ogres have layers. End of story. Bye-bye..."(C)Shrek.
Best regards,
Igor
-
October 1st, 2004, 05:56 AM
#73
Re: What do you prepend your class names with?
 Originally Posted by jfaust
I don't care what data type it is. The intent is clear. What do I care is it's an empty string, a 0 int, a null pointer or a class that has a cast to bool operator. We are checking for validity.
When you need to go more in depth and you are debugging or changing code, variables will either be declared locally (the more locally the better) or in the class header. If you are making changes, you should be intimately familiar with the area you are changing. The familiarity should go way beyond what type of data it is. You should understand the meaning and the intent.
You must be the luckiest programmer alive. No offense, but it doesn't look that you have ever worked on code written by somebody else. Especially if that code was written in 20 years by more than a single person. Conventions are good and you usually learn this when you struggle to work with someone who doesn't give a heck about them.
Har Har
-
October 1st, 2004, 09:34 AM
#74
Re: What do you prepend your class names with?
I always prepend classes with C. It makes it much easier to distinguish classes from other things, but well... it's just my opinion
-
October 1st, 2004, 12:23 PM
#75
Re: What do you prepend your class names with?
 Originally Posted by PadexArt
You must be the luckiest programmer alive.  No offense, but it doesn't look that you have ever worked on code written by somebody else. Especially if that code was written in 20 years by more than a single person. Conventions are good and you usually learn this when you struggle to work with someone who doesn't give a heck about them.
One program I work on has code dating from 1965. The other started in 1990. I joined this company in 1997. The vast majority of the code I work on was not written by me. There used to be a naming convention for classes here (an additional 6 letters!) which I obliterated by proper use of namespaces. Yes, I renamed all the classes throughout many hundreds of thousands of lines of code. It was a slow-burn project that lasted 3 years. We do not use hungarian notation and our coding standard explicitly says to not use hungarian notation. I believe our code is the better for it.
Jeff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|