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 https://en.wikipedia.org/wiki/Hungarian_notation – Doc Brown Sep 05 '16 at 20:26
  • 1
    It was more a general Windows eco-system thing than a VB thing back in the 90s. – GrandmasterB Sep 05 '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 07 '16 at 08:06
  • Some relevant history from Joel http://www.joelonsoftware.com/articles/Wrong.html – RubberDuck Sep 07 '16 at 09:01
  • 2
    I've long preferred the term "Hungarian warts" for this. – JimmyJames Sep 07 '16 at 21:30
  • Possible duplicate of [What is the benefit of not using Hungarian notation?](https://softwareengineering.stackexchange.com/questions/102689/what-is-the-benefit-of-not-using-hungarian-notation) – gnat Jun 21 '17 at 22:09
  • I had the "what happened to Hungarian?" question too. Wrote-up [my thoughts here](http://reconvolution.blogspot.com/2014/07/what-happened-to-hungarian-notation.html). – Nick Alexeev Sep 25 '18 at 23:06
  • conjBecause pnIt vIs adjBad prepFor nReadability. – dan04 Sep 25 '18 at 23:14
  • I still use Hungarian notation (VB.Net) - it makes programming much quicker, as I can get pick up my variables in Intellisense much faster, without having to memorize names. I program quickly, and for me it makes more sense to use it in VB.Net as the Intellisense is so much better compared to VB6. – Kevin Matney Sep 25 '18 at 20:36

1 Answers1

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.

JacquesB
  • 57,310
  • 21
  • 127
  • 176
  • 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 05 '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 05 '16 at 21:03
  • 4
    Ah come on, Null should at least get an honorable mention. – candied_orange Sep 05 '16 at 21:47
  • 1
    @BryanOakley I agree with you partially. One could also blame most bad OOP authors and instructors for the overuse of inheritance. Texts and lessons present trivial data manipulation problems (most of which should actually be solved with a hash table and just a few functions) and propose inheritance (sometimes a big inheritance tree) as a good, exemplary solution. – Bernardo Sulzbach Sep 05 '16 at 22:27
  • 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 06 '16 at 00: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 06 '16 at 08:54
  • @RubberDuck If everything's a `Variant`, Systems Hungarian would have you prefixing *everything* with `v` or `vrnt` or some such thing, which seems pretty useless. Perhaps you're thinking of Apps Hungarian, in which you prefix with types the compiler/interpreter is not aware of and/or does not enforce (e.g. prefixing one `string` with `ss` to indicate that it's a **S**afe **S**tring, sanitized for HTML vs prefixing with `us` to indicate that it's an **U**nsafe **S**tring, even though both are really just `\0` terminated character arrays)? – 8bittree Sep 06 '16 at 16:52
  • No @8bittree. I mean Systems Hungarian, where you indicate the actual data type like `iCount`. Think about how useful it is to see `iCount = sCount`. So, yeah. Kind of Apps Hungarian, but using what are traditionally seen as Systems prefixes (i, str, etc.) because there are no damned types. – RubberDuck Sep 06 '16 at 16:55
  • @RubberDuck: Indeed the conventions mandates the `vnt` prefix for variants. I have updated the answer to mention this. – JacquesB Sep 07 '16 at 08:01