Hungarian naming has fallen out of favor to a large degree. There are
two variants of it. Apps Hungarian is closer to the original proposal
by Charles Simonyi. In this approach, at design time, there is a
conscious, group-wide decision about the types to be used and their
corresponding prefixes. These types are usually specific to a
particular problem-domain and are not useful to universalize. Also, the
development environments used in recent years have obviated the need to
hyper-type variables to a large degree. The 'type' of the variable
appears when the cursor hovers over the variable.
The other variant (Systems Hungarian) was an almost useless, lazy
version. It only spoke to the underlying base data type, and probably
helped to hold systems programming back rather than propel it forward.
Maybe people familiar with the System Hungarian eschew Hungarian
notation altogether and assert quite rightly that with object-oriented,
the only way to know the real type of something is to look at the class
definition.
Typical recommendations are: 1) Don't use it at all, 2) Don't use it
unless you are in a problem space that already uses a set of prefixes,
3) Don't use System Hungarian, 4) Don't use it if you are using
object-oriented and have good tools, 5) If you feel the need for
Hungarian, you should be using an object anyway.
What I've settled throughe experience is to use it if the environment
already has it, and in small doses for poor-man's objects. That is,
use it hungarian or objects, but not both.
For example, If you have a buffer, it may be stored in aMyBuffer or
achMyBuffer, but you need a pointer, so that's pMyBuffer or
pchMyBuffer, but maybe you need a count of the length and size, that's
nMyBufferLength and nMyBufferSize. And, finally, maybe you need some
offsets into the buffer, that might be iMyBuffer, jMyBuffer, etc.
Buffers are so commonly used that it typically doesn't make sense to
make them objects...unless as in our case, we are making them do more
than just be buffers. And, yes, that's a statement that's likely to
spawn a large firestorm in the wrong forum, but the caveat is 'be more
than just buffers'. So, for these little objects, it makes sense to use
hungarian to keep track that all of these MyBuffer things are related
to the same thing.
Used in small does this well helps to remind us that there is a
MyBuffer 'object' which the typical attributes, and we need to maintain
certain invariants as we manipulate it.
'a' is array.
'n' and 'c' are count.
'sz' is null-terminated string.
'ch' is character.
'i' is index.
'p' is pointer.
'cs' is ColorState I s'pose.
'm_' is class member although that's technically not hungarian.
'g_' is global variable althought that's technical not hungarian.
So, m_acs is class member which is an array of color state. m_ach is
class member which is an array of characters.
Brazil