Common Variable-Name Prefixes

I am attempting to bring a little conformity and increased readability to my programming.

I wonder if anyone could point me towards a list of widespread or accepted prefixes that correspond to data types? I know a few common ones like 'c' for a char, 'sz' - although some seem to use 'str' - for a char array, 'w' for word and so on.

Over the years I have tended either to use long, descriptive names for my variables or attempted to mint my own prefixes. Both approaches have their values but also their fairly severe drawbacks; usually increasingly untidy code or increasingly cryptic and arbitrary letter combinations.

There seems to be a clear dichotomy, logically enough between prefixes commonly used for C++ programming as a whole and then more specialized prefixes for Windows programming. Moreover, while I have never written a programme for Unix I do not doubt that environment also has its own separate ecosystem of common prefixes as well.
I'm not sure of a list myself, but you could probably google 'Hungarian Notation' or something like that to get your prefixes.

Those prefixes are largely used in Windows programming, but personally I don't think that having prefixes based on types for your variables is the best idea. You generally don't need to know what exact type your variable is - rather, just give a one-word description of its purpose. Of course, rarely you will need to know exactly what type the variable is, but often it doesn't matter.

For examples of why Hungarian Notation may not be the best choice, read this: http://herbsutter.com/2008/07/15/hungarian-notation-is-clearly-goodbad/
Interesting stuff NT3 - that does give me quite a bit to think about!

Maybe very basic prefixes might still be considered useful though - like 'p' denoting a pointer and so forth? I myself find that quite handy to know if you have a long function and have scrolled past the declaration area.

At the end of the day I guess its 'horses for courses' - you use whatever you are most comfortable with. I myself have programmed in C++ for nearly twenty years - strictly as an amateur - but I am now having a real push to try to learn the language 'properly' as it were and produce the most professional code I can while still using ideas and methods that seem logical to me. This is giving me a lot questions as I am trying to challenge all my existing preconceptions about how to do set tasks.

I will certainly have a look at the 'Hungarian Notation' thing - I am sure I have come across that concept from time to time, but never really looked in to it properly.
Topic archived. No new replies allowed.