Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Why the world hates Hungarian notation?

Why the world hates Hungarian notation?

Scheduled Pinned Locked Moved The Lounge
questioncsharpc++collaborationtutorial
96 Posts 54 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Eytukan

    I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )

    Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

    R Offline
    R Offline
    R Giskard Reventlov
    wrote on last edited by
    #7

    It's far too easy to get really anal over naming conventions. Whilst I no longer use Hungarian I can't condemn anyone that does. Why? Because there is nothing wrong with it as long as its use is applied consistently throughout the project. Yes, it might look a little weird to me, but my code might look weird to you; doesn't mean it's bad code; just means we have differing naming convention preferences. Do what you want as long as it does no harm.

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

    E 1 Reply Last reply
    0
    • P PIEBALDconsult

      I've never liked it from the first time I saw it (it was in the standard at one place I worked -- using C) and I never use it in my own code. It's silly and you would have to change the variable name if you change the datatype. Having said that; here's the right way: http://www.joelonsoftware.com/articles/Wrong.html[^]

      V Offline
      V Offline
      Vark111
      wrote on last edited by
      #8

      This has always bee my point of view on Hungarian. If you're using Hungarian to show you type info (i.e. compiler types, not semantic types), then you're using Hungarian wrong. Wrong Hungarian = bad. Right Hungarian = good. I currently don't trust anyone on my team to write "right Hungarian", though, so we outlaw it altogether at my workplace.

      G 1 Reply Last reply
      0
      • R R Giskard Reventlov

        It's far too easy to get really anal over naming conventions. Whilst I no longer use Hungarian I can't condemn anyone that does. Why? Because there is nothing wrong with it as long as its use is applied consistently throughout the project. Yes, it might look a little weird to me, but my code might look weird to you; doesn't mean it's bad code; just means we have differing naming convention preferences. Do what you want as long as it does no harm.

        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

        E Offline
        E Offline
        Eytukan
        wrote on last edited by
        #9

        I'm finding it difficult to review the code in notepad. The purpose of the review is to shoot down all the unreasonable use of static variables. But unless I copy the entire project and get the roots of all these variables, I wont be able to step into the code review. it's bad.

        Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

        R R R T 4 Replies Last reply
        0
        • E Eytukan

          I'm finding it difficult to review the code in notepad. The purpose of the review is to shoot down all the unreasonable use of static variables. But unless I copy the entire project and get the roots of all these variables, I wont be able to step into the code review. it's bad.

          Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #10

          VuNic wrote:

          I'm finding it difficult to review the code in notepad.

          IMHO that's your problem.  Sure, Hungarian notation may allow you to easily identify the type of a variable (assuming the type hasn't changed since the variable was named), but I recommend using a tool like VS to do a proper code review. /ravi

          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

          1 Reply Last reply
          0
          • N Nish Nishant

            Well I've got to say that between lAccNum and accountNumber, the latter clearly indicates what the type is.

            Regards, Nish


            My technology blog: voidnish.wordpress.com

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #11

            Nish Sivakumar wrote:

            ...accountNumber, the latter clearly indicates what the type is.

            What type is it: numeric (long, int, double) or alphanumeric?

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            N 1 Reply Last reply
            0
            • E Eytukan

              I'm finding it difficult to review the code in notepad. The purpose of the review is to shoot down all the unreasonable use of static variables. But unless I copy the entire project and get the roots of all these variables, I wont be able to step into the code review. it's bad.

              Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

              R Offline
              R Offline
              R Giskard Reventlov
              wrote on last edited by
              #12

              If it suits what you're doing then go for it: don't listen to all the crazies and their pedantic rants about how stuff should get done.

              "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

              1 Reply Last reply
              0
              • C Chris Meech

                Nish Sivakumar wrote:

                accountNumber, the latter clearly indicates what the type is

                You've obviously not worked on some of the databases that I've had to support.

                ...
                ,AccountNumber VARCHAR(30) NOT NULL
                ...

                Though to your credit, hungarian notation probably wouldn't help things out, much. :)

                Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

                N Offline
                N Offline
                Nish Nishant
                wrote on last edited by
                #13

                Yeah, account number was probably a bad choice for my example :-)

                Regards, Nish


                My technology blog: voidnish.wordpress.com

                G 1 Reply Last reply
                0
                • E Eytukan

                  I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )

                  Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

                  E Offline
                  E Offline
                  Ennis Ray Lynch Jr
                  wrote on last edited by
                  #14

                  As an aside, the .NET world is vehemently opposed to Hungarian notation yet the prefix _ is ok. WTF. I would rather use m than _ any day of the week. At least m stands for something. Of course, the reason the _ is even necessary is because of VB.NET.

                  Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

                  T 1 Reply Last reply
                  0
                  • D David Crow

                    Nish Sivakumar wrote:

                    ...accountNumber, the latter clearly indicates what the type is.

                    What type is it: numeric (long, int, double) or alphanumeric?

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                    N Offline
                    N Offline
                    Nish Nishant
                    wrote on last edited by
                    #15

                    DavidCrow wrote:

                    What type is it: numeric (long, int, double) or alphanumeric?

                    If I see accountNumber, I'd automatically assume an Int32 (.NET).

                    Regards, Nish


                    My technology blog: voidnish.wordpress.com

                    D R G W M 5 Replies Last reply
                    0
                    • P PIEBALDconsult

                      I've never liked it from the first time I saw it (it was in the standard at one place I worked -- using C) and I never use it in my own code. It's silly and you would have to change the variable name if you change the datatype. Having said that; here's the right way: http://www.joelonsoftware.com/articles/Wrong.html[^]

                      N Offline
                      N Offline
                      Nagy Vilmos
                      wrote on last edited by
                      #16

                      Only one 5 available, sorry. That is a very good example of doing things for the right reason. Bookmarked. :thumbsup::thumbsup::thumbsup::thumbsup::thumbsup:


                      Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                      1 Reply Last reply
                      0
                      • E Eytukan

                        I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )

                        Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

                        M Offline
                        M Offline
                        Maximilien
                        wrote on last edited by
                        #17

                        Using meaningful variable names reduce the need to artificially decorate variable name. And in 2012, intellisense type technology makes it easier to keep tab of what type are the variables you are using. IMO, using notepad to do code-review is counter-productive.

                        Watched code never compiles.

                        E 1 Reply Last reply
                        0
                        • M Maximilien

                          Using meaningful variable names reduce the need to artificially decorate variable name. And in 2012, intellisense type technology makes it easier to keep tab of what type are the variables you are using. IMO, using notepad to do code-review is counter-productive.

                          Watched code never compiles.

                          E Offline
                          E Offline
                          Eytukan
                          wrote on last edited by
                          #18

                          Actually I intentionally put that as Notepad though I would be using an IDE for the code review. Because to me both IDE and notepad would mean the same unless I copy the entire project for the review.

                          Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

                          T 1 Reply Last reply
                          0
                          • N Nagy Vilmos

                            I read 'nation' to start with and I was ready with :mad:, but I'll forgive you. This once. Hungarian notation works, as you say, well and you always know what the data type is. If you don't use it then you need to go back to the point in the code at which the variable was defined. This was indeed a problem using old fashioned non-contextual editors. With the use of modern IDE's, you can easily see the data type because of IntelliSense. I personally do not use Hungarian notation anymor, but I understand and appreciate its usefulness.


                            Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #19

                            Nagy Vilmos wrote:

                            I personally do not use Hungarian notation anymor

                            Nagy Vilmos? ;)

                            Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

                            1 Reply Last reply
                            0
                            • E Eytukan

                              I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )

                              Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

                              S Offline
                              S Offline
                              Steve Maier
                              wrote on last edited by
                              #20

                              For me, I used to use Hungarian when I was coding in MFC and C++. Now that I have been using .NET I don't use it for a few reasons. The modern IDE can show you the type very easily. People have changed types and then were lazy to rename the variables. Names like these are like specs, they get out of date pretty quickly. Some people on my team use the old m_ or just m to say member variable. One person just uses an _ but at the end of the name, not the beginning. So typically since it is a religious war when it comes to things like this or where he proper place to put the curly braces, we typically just state to follow the coding convention that the person wrote the code in. If you cannot understand it, then I really don't want you on my team anyways. ;) Of course taking home 300 lines of code from your work is actually concidered IP theft where I work unless you have a company laptop and can VPN in. That and then picking notepad to view the code is just not right. At least get Notepad+.

                              Steve Maier

                              1 Reply Last reply
                              0
                              • E Eytukan

                                I'm about to write the coding standards doc for a team. I've been using Hungarian notation ever since I stated coding. The blogs that I read online rant against use of Hu system on OO languages, but I have few questions: Though it's C++ or C#, we do have primitive data types everywhere. In fact, for smaller projects, primitive data types would account for 90% of the variables. Now I'm dealing with a lot of nummbers , flags & so on. How do I know what datatype it is? For example, the code is a 100K line code and I cannot copy the entire project to my disk to review that at home. I choose to copy a 300 lines code block with multiple functions to review it at home. I just open it in notepad and try to figure out what datatypes all these variables are. No where I can figure out this. Then why the heck everybody rants against this convention? I'm going ahead insisting on sticking with the Hu notion. If anybody has a valid reason against it, I'm all ears to it. (if you dont like Hu notation, please dont express it with the 1 vote here :sigh: )

                                Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

                                T Offline
                                T Offline
                                TheGreatAndPowerfulOz
                                wrote on last edited by
                                #21

                                Because most people do it incorrectly. The guy, Simonyi, who invented Hungarian notation meant for the names of variables to carry the kind of thing it is, not its type. So, instead of

                                int iRowScr, iColScr.
                                List ilBal;

                                you'd have

                                int rwScreen, colScreen;
                                List Balances;

                                He never intended for the variable name to carry the underlying type, but rather the name should be informative of what it is.

                                If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
                                You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

                                1 Reply Last reply
                                0
                                • P PIEBALDconsult

                                  I've never liked it from the first time I saw it (it was in the standard at one place I worked -- using C) and I never use it in my own code. It's silly and you would have to change the variable name if you change the datatype. Having said that; here's the right way: http://www.joelonsoftware.com/articles/Wrong.html[^]

                                  N Offline
                                  N Offline
                                  Nelek
                                  wrote on last edited by
                                  #22

                                  Same answer as NagyV

                                  Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.

                                  1 Reply Last reply
                                  0
                                  • N Nish Nishant

                                    DavidCrow wrote:

                                    What type is it: numeric (long, int, double) or alphanumeric?

                                    If I see accountNumber, I'd automatically assume an Int32 (.NET).

                                    Regards, Nish


                                    My technology blog: voidnish.wordpress.com

                                    D Offline
                                    D Offline
                                    Dr Walt Fair PE
                                    wrote on last edited by
                                    #23

                                    And I'd automatically assume it might have hyphens and/or spaces and should be alphanumeric. Hence I agree with the OP's idea. Personally I think all edicts are counter productive. I tend to use Hu notation for a few things in C# mainly because I know my conventions and it makes things easier to remember and find.

                                    CQ de W5ALT

                                    Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

                                    N 1 Reply Last reply
                                    0
                                    • D Dr Walt Fair PE

                                      And I'd automatically assume it might have hyphens and/or spaces and should be alphanumeric. Hence I agree with the OP's idea. Personally I think all edicts are counter productive. I tend to use Hu notation for a few things in C# mainly because I know my conventions and it makes things easier to remember and find.

                                      CQ de W5ALT

                                      Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

                                      N Offline
                                      N Offline
                                      Nish Nishant
                                      wrote on last edited by
                                      #24

                                      Walt Fair, Jr. wrote:

                                      And I'd automatically assume it might have hyphens and/or spaces and should be alphanumeric.

                                      It depends on the quality of your fellow devs. Most devs I work with would not have "number" in an identifier if it represents a string.

                                      Regards, Nish


                                      My technology blog: voidnish.wordpress.com

                                      D 1 Reply Last reply
                                      0
                                      • N Nish Nishant

                                        DavidCrow wrote:

                                        What type is it: numeric (long, int, double) or alphanumeric?

                                        If I see accountNumber, I'd automatically assume an Int32 (.NET).

                                        Regards, Nish


                                        My technology blog: voidnish.wordpress.com

                                        R Offline
                                        R Offline
                                        Roger Wright
                                        wrote on last edited by
                                        #25

                                        In every accounting system I've ever used, your assumption would be wrong. ;P

                                        Will Rogers never met me.

                                        N J 2 Replies Last reply
                                        0
                                        • R Roger Wright

                                          In every accounting system I've ever used, your assumption would be wrong. ;P

                                          Will Rogers never met me.

                                          N Offline
                                          N Offline
                                          Nish Nishant
                                          wrote on last edited by
                                          #26

                                          Roger Wright wrote:

                                          In every accounting system I've ever used, your assumption would be wrong. ;-P

                                          Then perhaps, I'd rename that to accountIdentifier or accountId.

                                          Regards, Nish


                                          My technology blog: voidnish.wordpress.com

                                          F 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups