Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hungarian in VBA okay?

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.

like image 860
KennerL90 Avatar asked Apr 03 '10 22:04

KennerL90


People also ask

Why not to use Hungarian notation?

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.

Is Hungarian Notation good?

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.

What is Hungarian notation example?

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.

Does VBA support try catch?

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.


2 Answers

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?

like image 112
Earlz Avatar answered Sep 25 '22 18:09

Earlz


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 string, call it a name or an address, and instead of an int, call it a count or a coordinate or ...

(I prefer to use suffixes to prefixes, but that's a matter of style and taste.)

like image 39
Donal Fellows Avatar answered Sep 22 '22 18:09

Donal Fellows