Pergunta

Kind of as the title implies - I can understand why Apps Hungarian might crop up, but Systems Hungarian seems almost entirely pointless in a strongly-typed language. Why, then, is it so apparently prevalent in the VB world? Going back to my high school programming courses (late '00s), I had a teacher who knew nearly nothing about programming, but adhered to Systems Hungarian religiously.

I just find it odd that this naming standard persists, even in places it shouldn't (like column names in databases), and the specificity of the environments in which it does. Can anyone shed some light on this?

Foi útil?

Solução

Microsoft, the creator of VB, have pushed so-called "Systems Hungarian" in their documentation and examples. The Constant and Variable Naming Conventions in their Visual Basic Programmers Guide explicitly mandates Hungarian:

Variables should be prefixed to indicate their data type. Optionally, especially for large programs, the prefix can be extended to indicate the scope of the variable.

In the chapter Data Types you see examples like:

Dim intX As Integer
Dim blnRunning As Boolean

Dim objDb As Object
Set objDb = OpenDatabase("c:\Vb5\Biblio.mdb")

There are standard prefixes for all the built-in VB types. Most absurdly the prefix udt is mandated for user defined types and vnt-prefix for variants.

From Microsoft this practice has spread through coding standards, examples and tutorials, and have been adopted by the VB community at large - at least until MS realized the uselessness of Hungarian notation around the transition to VB.Net.

As for why it is used nowhere else? Because it is the stupidest and most useless idea in programming history.

Licenciado em: CC-BY-SA com atribuição
scroll top