I don't use hungarian (str, int) prefixes in .Net, but I still find it useful in VBA, where it is more difficult to see types.
Is this bad? Unnecessary? Maybe I'm missing something.
I'd really appreciate any feedback. I've been wondering for a while.
Thanks everybody.
Some potential issues are: The Hungarian notation is redundant when type-checking is done by the compiler. Compilers for languages providing strict type-checking, such as Pascal, ensure the usage of a variable is consistent with its type automatically; checks by eye are redundant and subject to human error.
In general, Hungarian Notation has fallen out of fashion. In strongly-typed languages, it's broadly redundant, especially the Systems Hungarian type. It can also make code more difficult to read. Any problems it might help solve are often signs of deeper flaws, such as an over-reliance on global variables.
In Systems Hungarian notation, the prefix represents the actual data type of the object. For instance, if the object named Greeting were a zero-terminated string, its Systems Hungarian name might be szGreeting. Or, if the object YesOrNo were a boolean variable, its Systems Hungarian name would be bYesOrNo.
The Try-Catch method prevents program crashes when an internal error occurs in computer programming. It is useful to prevent system errors and let the smooth flow of code execution occur. However, unlike other programming languages, VBA does not have the Try-Catch block.
I would say that this kind of Hungarian notation is the root of all evils in almost every language. Some people say it is handy for extremely dynamic languages. But no, I think that prefixing the type-abbreviation onto a variable name is redundant in 99% of all cases and just leads to ugly code.
see Why Shouldn't I Use Hungarian Notation?
I'd advise going for something a little higher-level than just types so that you can see what the purpose of things are. Thus, instead of calling something a str
ing, call it a name
or an addr
ess, and instead of an int
, call it a count
or a coord
inate or ...
(I prefer to use suffixes to prefixes, but that's a matter of style and taste.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With