CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

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

    2 2.82%
  • A "C" because Microsoft does it

    2 2.82%
  • A "C" because it denotes "class"

    22 30.99%
  • A "C" -- doesn't this have to do with something to do with hungarian notation or something like it?

    6 8.45%
  • A "C" for my own reasons

    2 2.82%
  • A "T" like Borland used to do

    1 1.41%
  • Something else

    5 7.04%
  • Nothing -- my class names are clearer without a leading letter.

    26 36.62%
  • "There's no place like home. There's no place like home. There's no place like home."

    2 2.82%
  • A "C" because VC6's MFC class wizard adds it for me

    3 4.23%
Page 5 of 6 FirstFirst ... 23456 LastLast
Results 61 to 75 of 76
  1. #61
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: What do you prepend your class names with?

    Much Ado About Nothing
    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

  2. #62
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: What do you prepend your class names with?

    Quote 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.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #63
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    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

  4. #64
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: What do you prepend your class names with?

    Quote Originally Posted by TheCPUWizard
    My comment was a PUN.
    Well...
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  5. #65
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: What do you prepend your class names with?

    Quote Originally Posted by TheCPUWizard
    My comment was a PUN.
    Did You mean a Physical Unit Number?
    Best regards,
    Igor

  6. #66
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: What do you prepend your class names with?

    Hey guys, don't pollute the thread with out-of-topic chat.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  7. #67
    Join Date
    Nov 2002
    Location
    Foggy California
    Posts
    1,245

    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

  8. #68
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582

    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

  9. #69
    Join Date
    Oct 2003
    Location
    Romania
    Posts
    127

    Re: What do you prepend your class names with?

    Quote Originally Posted by TheCPUWizard
    I am well familiar with Shakespeares work.
    To prepend, or not prepend: that is the question...

  10. #70
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: What do you prepend your class names with?

    Quote 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

  11. #71
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582

    Re: What do you prepend your class names with?

    Quote 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.

    Code:
    if( someVal )
    ...
    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

  12. #72
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    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

  13. #73
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: What do you prepend your class names with?

    Quote 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

  14. #74
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    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
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  15. #75
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582

    Re: What do you prepend your class names with?

    Quote 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

Page 5 of 6 FirstFirst ... 23456 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured