3

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?

  • 2
    I doubt it is popular in "the VB world", especially not today among VB.NET programmers. What makes you think it is? This one teacher you had? It was popular for a certain period in Windows programming, specifically using C, and you find some reminiscents to this in the Windows API, see en.wikipedia.org/wiki/Hungarian_notation – Doc Brown Sep 5 '16 at 20:26
  • 1
    It was more a general Windows eco-system thing than a VB thing back in the 90s. – GrandmasterB Sep 5 '16 at 20:49
  • in the 1990's in microsoft certification exams, they would just use variable names and expect you to know the object type from the name, e.g. cbo, btn, lbl etc... – Michael Shaw Sep 7 '16 at 8:06
  • Some relevant history from Joel joelonsoftware.com/articles/Wrong.html – RubberDuck Sep 7 '16 at 9:01
  • 2
    I've long preferred the term "Hungarian warts" for this. – JimmyJames Sep 7 '16 at 21:30
12

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.

  • 2
    +1 for "Because it is the stupidest and most useless idea in programming history", though I'd contest that it's actually only the 2nd most stupidest and most useless idea in programming history, with inheritance taking 1st place ;) – David Arno Sep 5 '16 at 20:59
  • 6
    @DavidArno: I would argue that inheritance is equally as valuable as threading, and nearly as hard to use correctly. Beginners see it as the solution to all their problems (and they would be wrong, of course), but In the right hands inheritance is a very useful construct. – Bryan Oakley Sep 5 '16 at 21:03
  • 4
    Ah come on, Null should at least get an honorable mention. – candied_orange Sep 5 '16 at 21:47
  • 5
    Systems Hungarian actually makes a ton of sense in the context of VBScript, where everything is a Variant. As a former VB guy, weakly typed languages are the only place it makes sense. It certainly has no place in VB6, let alone VB.Net. – RubberDuck Sep 6 '16 at 0:15
  • 4
    There are lots of candidates for stupid and useless ideas. Yoda conditions and single point of entry / single point of return rank right up there with hungarian notation. Inheritance doesn't come even close. – David Hammen Sep 6 '16 at 8:54

protected by gnat Sep 25 '18 at 20:54

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.