I really don't understand why everyone prepends their classes with "C". What are your thoughts about this practice?
Printable View
I really don't understand why everyone prepends their classes with "C". What are your thoughts about this practice?
C stands for "class" in the class name. However, borland VCL uses T letter which stands for "type" evidently. You can or cannot adopt any prepending letter - nobody could force you to do it (except your employer I suppose :))
I've heard the "C stands for class" and "T stands for type" theory before. If you think about it, if you're declaring a variable, it should either be (a) a fundamental type [which are easy to spot] (b) a class or (c) an enumeration. Is it really that difficult for someone reading the code to identify what's a class and what isn't? (And if we follow this thought, all enumerations should begin with "E")
Some recent books I have read have stated that "C" and "T" were really used to avoid naming conflicts with other class names -- both these syntaxes were adopted before namespaces were created. But if everyone used "C" (again w/o namespaces), then name conflicts were just as likely to occur.
Personally, I don't think a "C" makes anything look more clear. But again, that's just my feelings on the subject.
Personally, I care less with what is to be prepended.
Well... actually I go by convenience..
I have worked in projects where a we used a specific Abbr prepended to all classes in the system to denote something which was written as a part of the implementation of the project... So, when one looks at the class name it is easier to know where to look for.
Actually, I like it when things related to a particular system, if I may say so, be easily identifiable..
I agree, but that indicates that you don't always prepend with the same letter. I often do similar things using short abbreviations so that I know where to look for things. But I have seen some applications where every class has a "C" in front. I am used to it and it doesn't disrupt my thought or anything. I am just curious why the practice is so prevalent. That's why I posted so many options in the poll.Quote:
Originally Posted by kirants
I dunno either. When I initially started off working with MFC, I did have that habit ( of prepending a "C" ), but I have gotten rid of that now..
I try to be more meaningful now..
It doesn't make sense to use "C" as such.. Class names aren't as stringent as using __ or _ in front of variables/functions.
Well, well... I've never claimed it's absolute and final truth.Quote:
Originally Posted by KevinHall
I'd thought about it. Few times. :) And became to conclusion that when you use (or not) any prepending symbols it could be just a sort of habit in most cases.Quote:
If you think about it, if you're declaring a variable, it should either be (a) a fundamental type [which are easy to spot] (b) a class or (c) an enumeration. Is it really that difficult for someone reading the code to identify what's a class and what isn't? (And if we follow this thought, all enumerations should begin with "E")
When it's not a habit it could be caused by some kind of agreement - verbal or documented (obeying to company programming standard) - and in this case you'll never ask "WHY" because you already know the reason.
Well, it looks quite believable.Quote:
Some recent books I have read have stated that "C" and "T" were really used to avoid naming conflicts with other class names -- both these syntaxes were adopted before namespaces were created.
Most people adopt habits of others quite easily when they have no reason to oppose them. :)Quote:
But if everyone used "C" (again w/o namespaces), then name conflicts were just as likely to occur.
Really, not so many people face to a name conflict. But if they were they taught to use namespaces very quickly.
About "everyone"... I admit that C letter's used very often in win programming - suppose, 'cause MS bless such practice just as they bless hungarian notation and many other things. Finally, all that tiny habits form a sort of environment, atmosphere, aura... Some creatures breathe freely there, but some not.
Programming is just a kind of social life where common sense, rules, habits, public and private opinions coexist. Move to other country (Linux) and you'll find yourself in rather different world. :)
Yeah, it's just your feeling. It's not right or wrong. It just is.Quote:
Personally, I don't think a "C" makes anything look more clear. But again, that's just my feelings on the subject.
A "C" because it denotes "class", because Microsoft does it, for my own reasons, and because everyone else (should) do it.
I agree with Hokutata and I think the poll should have used check buttons instead of radio buttons.
And by the way, the word prepend is not actually a word. It doesn't exist in any english dictionary (that I have :D ).
Well...just because Microsoft does it, or you do it will not make me convinced that I have to do it as well... :eek:Quote:
Originally Posted by Hokutata
Prepend definition from dictionary.com
Please expand on this. I'm really curious why you hold this belief.Quote:
Originally Posted by Hokutata
Well Andreas, paying more attention, we can observe that Hokutata found more reasons to use "C" than just because Microsoft does it.Quote:
Originally Posted by Andreas Masur
Anyhow even the OP (KevinHall) put more items pro "C" in this poll (the score is 5-4). So, better is to do it ;)
Not on my watch. :DQuote:
Originally Posted by ovidiucucu
Well...no...I did it for sometime as well....getting forced by my company...however, I drift away from the whole hungarian notation (which is where this one was introduced) since these kind of notations do not make much sense in an object-oriented language anyway...Quote:
Originally Posted by ovidiucucu