Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
PC Games (Games)

Journal Chacham's Journal: Verbiage: So *that's* where Hungarian Notation went wrong. 13

Getting into coding consistently bothers me because of the annoying practice of many programmers to put the variable type before the variable itself. I do not like it for three reasons. One, it's redundant. Two, it's ugly. Three, it prepends a constraint to the object in the name.

On complaining to the others who use it, i'm told that it helps a coder quickly get into something because he does not need to look back for the declaration. However, if the programmer is not looking back, i don't want him touching my code anyway. Either you know the variable personally, or you don't know it at all. And that notation simply helps the slackers.

IMNSHO, this programming style is used by (MBTI) Ps, and hated by Js. This is also one of those times i think the P should give in to the J because laziness in coding can have disastrous consequences.

This type of coding is mistakenly called Hungarian Notation. Created by a Hungarian Microsoft programmer, and looking odd, it got its name. However, this is not Hungarian Notation.

[EDIT: 7/27/2014 Removed link and snippet.]

So, i used to say i hated Hungarian Notation, i can now revise that. Hungarian Notation is a wonderful in many environments. The only difference is, i use it slightly differently. I use it hierarchically. For example, when creating a schema in a database, if there is a subset of TABLEs, i will usually pick a short prefix and use it on all the TABLEs. CONSTRAINT names are somewhat similar.

In vaiables, if a variable is specific to an item, such as his example of an offset, i'd probably call it something like ListBox_Offset. That is, if the list box was called Process_List (i use both underscores and mixed case for readability) it would be Process_list_Offset. Well, the scenario will change it based on context and use, but everything that has to do with Process_List, will get exactly that, plus an underscore, as a preface.

And finally, if for some reason i had to specify the variable type, it'd be at the end, not at the beginning. There is no int class that has my variable within it. Int is merely a constraint on the variable.

I have not read the Microsoft paper yet. I think i shall get to that soon enough.

This discussion has been archived. No new comments can be posted.

Verbiage: So *that's* where Hungarian Notation went wrong.

Comments Filter:
  • ...we adopt what we like best, and avoid the rest. I hadn't been privy to the "systems vs. apps" divide, but in skimming that MS article on HN from 1999, I see that I fall squarely in the systems camp. I never liked stuff like prefixing 'c' for count and 'd' for difference and 'f' for flag and that other whole host of things. I don't need to decipher a whole mini meta language inside my variable names.

    As many Windows programmers did, at least at the time, we cut our teeth on the Petzold volume mentioned in
    • Perpetuating evil again cus it's easy? :)

      I've never coded in that style, and i never plan too. I was once almost forced to so i wrote it normally and was going to add the ridiculous notation later. Luckily, they relented.

      There's nothing like a clear variable name inside a well documented program. Mangled Hungarian Notation is just plain bad coding for lazy programmers. Fitting in or not, there's no reason to continue it.

      You say it's to fit in. That's an excuse not to fight. I guess i can't fault you for it,
      • "Wrong"? "Evil"? Oh, you fit in so well here! That it's 2006 and people are still starving and dying of AIDS etc. is wrong and evil. Not HN or OS's or languages or whatever else the average Slashdotter is having religion over these days.

        When you program for a living, you tow the stylistic guidelines if you want to keep your job, and not have all your coworkers hate you. At my previous job a developer was fired after repeated warnings, for not following the established coding style, and for forgetting to che
        • I use a similar notation, and it has made me more efficient. It's easier for me to interpret code in the center of a function, it permits more focus in my comments on performed actions, and it facilitates my reunderstanding of code that I haven't touched in a couple of years.

          I've worked without it where I had to, such as RPG/400 where every variable name character counts, but elsewhere it's been a help -- especially when I'm looking at printouts or using an editor that doesn't quite qualify as an IDE. T

        • "Wrong"? "Evil"? Oh, you fit in so well here! That it's 2006 and people are still starving and dying of AIDS etc. is wrong and evil. Not HN or OS's or languages or whatever else the average Slashdotter is having religion over these days.

          Heh. I'm using "wrong" and "evil" a bit facetiously. Obviously, it can't be "wrong" because it is stylistic, and it can't be "evil" because there is no such thing.

          When you program for a living, you tow the stylistic guidelines if you want to keep your job, and not have all y
          • ...and it can't be "evil" because there is no such thing.

            That I better leave for another time! :-)

            I wouldn't want to work at a company that demands a certain coding standard. I think they don't actually help anybody...

            While you're welcome to your opinion, this coder who's been in the trenches for 10 years now says it's a big help when the codebase looks relatively the same.

            I think each large system is supposed to make up their own.

            Yup, that seems to have been the mad Hungarian's intent. If I may oversimplif
            • >...and it can't be "evil" because there is no such thing.

              That I better leave for another time! :-)


              Heh.

              While you're welcome to your opinion, this coder who's been in the trenches for 10 years now says it's a big help when the codebase looks relatively the same

              No change? Ought to get boring after a while.

              And, sometimes understanding the way another person thinks is important. Modifying that with so-called standards hinders that.

              and "Systems Hungarian" makes noobs and those less familiar more productive.

              Pr
              • Productive meaning being able to work on code they know nothing about, and will most likely add more bugs too. ... no thanx!

                Yep, exactly -- welcome to professional programming in corporate America. But dripping sarcasm aside for a moment, at least in business, they're run by business folk, and they know nothing about the nature of software development, so they unknowingly do this and many other dumb, to a technical person, things.

                Why hinder the coder's artistic style?

                Well, coding style at the level of syste
                • >In an API, that's a different story,...

                  To me it's the same thing -- being a good neighbor to your fellow programmer.


                  Not the same at all.

                  An API is specifically made for others who are not familiar with every call, and do not need to be familiar with it, so a consistent naming scheme makes finsing the right call easier, and even better as it makes finding the correct call easy as it will not be a different call with some obscure name.

                  A variable, however, is something a programmer should not be touching wi
  • Comment removed based on user account deletion
  • On complaining to the others who use it, i'm told that it helps a coder quickly get into something because he does not need to look back for the declaration.

    At the risk of throwing stones from within my glass house, if the functions are of appropriate size then you should be able to see the whole function on a single page. There should be no need to "look back". I know there are exceptions to this rule, but there are far more examples (many that I'm personally responsible for) that violate this rule wit

    • Yep.

      In learning .NET i am playing with a program right now. One sub set a whole bunch of things. So, after i finsihed it, i went back and separated each setting into it's own private sub, and call each sub from the main wondow. Now the main calling window is cleaner, being just a few lines, and is very clear on what is happening.

Solutions are obvious if one only has the optical power to observe them over the horizon. -- K.A. Arsdall

Working...