C what?

Started by
11 comments, last by DataQ 22 years, 1 month ago
What''s the deal with coders prefixing ''C'' on their classes? Does it stand for "Class"?
Advertisement
Yes. It''s simply lets you see at a glance that something is the name of a class, as opposed to a struct, typedef, or anything else.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
It's calles "Hungarian notation" and is somewhat a Win32 coding standard.. mostly because it's developed by a M$ empolyee.
Check out this link
I find it very useful, since it lets me see what kind of variable I declared two months ago just by looking at the name it has, like b for bool, c for char, C for class and sz for a null terminated string.. Also take a look at the Ellemtel standars

It's nothing wrong to do things right from the beginnig.
EDIT - all links should work now..

Wannabe

Edited by - Rickmeister on March 12, 2002 1:24:49 AM
i prefix my program STRUCTURES with a capatal letter to quickly identify probable usage.

Cclass
Sstruct
Uunion
Eenum

though, i dont think namespaces deserve a prefix.

as far as hungarian notation goes, i think its obsolete in MVC++, since datatype information is available/extrapolatable through the gui, naming conventions, fly declarations, and scope.

save pointers, which are less like datatypes than they let on,
pPointer
Ugh. I have an IDE. I place my mouse cursor over a variable identifier and it tells me its type. I place my cursor over a structure identifier and it tells me its declaration. I place my cursor over a function identifier and it tells me the function return type and parameters. What, then, do I need notation for?

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

You look over your code with your eyes faster than you move your mouse. That''s the reason for notation. Besides there is a small delay when you place the cursor and the type text appears.

-------------Ban KalvinB !
I usually go with Hungarian notation to some extent. The scope indicators are very useful, primarily m and g.

I sometimes also use Quake style naming conventions, particularly when I''m working on Quake engine derived code like Half Life. Most of half life is also written in this Hungarian-Carmackian notation style. The Quake, or Carmackian style of naming is:
An enum is enumname_e
A struct is structname_t
a union is unionname_u
And there''s nothing for classes, cause I''ve never seen classes in Quake code.

-----------------------------
Direct3D vs. OpenGL
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
Democracy is where you say what you want and do what you''re told.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
quote:Original post by granat
You look over your code with your eyes faster than you move your mouse. That''s the reason for notation. Besides there is a small delay when you place the cursor and the type text appears.

But I do much less typing in the long wrong. The only notations I emply are those that denote ownership. I sometimes prefix typedefs (because my IDE doesn''t provide any data on them, and IntelliSense ceases to function once you typedef).

Besides, as code evolves type notations often become untrue (see WPARAM/LPARAM and DWORD).

Use comments and descriptive variable names. That''s what they''re there for.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Just use what you find best. I have my own coding standards which i find easy to understand (and are a pain in the arse for some ppl because i used to be a vb programer).

If i was writing a program that heaps of people would be looking at the source code i would however use a coding standard like this (but i dont see that happening anytime soon).

#define BLOODY_WORK_THIS_TIME;
#define BLOODY_WORK_THIS_TIME;
quote:Original post by Oluseyi
Besides, as code evolves type notations often become untrue (see WPARAM/LPARAM and DWORD).


The exact same logic could be used as a reason not to comments. Just reread your previous statement and replace "type notations" with "comments" and you''ll see what I mean. However, that doesn''t mean you shouldn''t use comments, or HN.

quote:Original post by Oluseyi
Use comments and descriptive variable names. That''s what they''re there for.


Although this generally works in most cases, it doesn''t always work. Tell me what type a variable called OrderNumber is. Is it an int, unsigned int, string? You can''t tell from the variable name.

Also, it''s important to note that enabling Browse Info in VC6 can increase your compile time dramatically in large projects (Ok, at least it was dramatic in VC5, I haven''t recompiled our work project with VC6 or VC7 to test improvements on this). It already takes 30 minutes to do a full compile on our project at work (on a 1GHz Pentium computer) and that''s without using Browse Info.

Oh, and browse info does no good when you''re looking at a hard copy of your code (printout), reading from a book, etc.


However, I''m not saying I disagree with you, Oluseyi. Like you, I don''t use Hungarian Notation either. My point is just that it isn''t a black and white issue, there are both pros and cons for using or not using HN.


- Houdini
- Houdini

This topic is closed to new replies.

Advertisement