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. Hungarian notation

Hungarian notation

Scheduled Pinned Locked Moved The Lounge
csharpcomagentic-aijsonquestion
56 Posts 26 Posters 0 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.
  • C Christopher Duncan

    I've noticed that the C# folks at Microsoft have promoted a different naming convention that uses no variable type prefix. At the same time, I've observed that it's now trendy for people to dislike Hungarian notation. When I first started Windows programming Hungarian was indeed strange to get used to. But then, so was the Windows API. However, these days when I look at variable names without it and am left to either guess or search through the code to determine what the variable type is, I find myself thinking that these variable names are only one step removed from the old Basic days of names such as A, B, etc. Why would a straightforward and easy to grasp system of conveying crucial information to the programmer at a glance suddenly become so unpopular? Is there technical reasoning behind it, or is it just a new generation who feels that they must do things differently than those who came before in order to proclaim their identity?

    Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

    C Offline
    C Offline
    Clickok
    wrote on last edited by
    #30

    In some cases Hungarian notation is used yet to name controls of forms and webforms, like "textboxName" or "checkboxIsFlameWar".

    Christopher Duncan wrote:

    I find myself thinking that these variable names are only one step removed from the old Basic days of names such as A, B, etc.

    It's not a common situation. Usually you can determine what the variable type is with intellisense or reading the context (not true for javascript, of course). By example


    Engaged in learning of English grammar ;)
    For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life.(John 3:16) :badger:

    1 Reply Last reply
    0
    • C Chris Losinger

      MS said Jump Left, they all jumped left. MS said Jump Right, they all jumped right.

      image processing toolkits | batch image processing | blogging

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #31

      I think we were all waiting to jump away from that awful Hungarian notation, anyways. Microsoft just gave us an excuse to ditch it for good.

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: Check out this cutie The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

      1 Reply Last reply
      0
      • Z zoid

        really? There are many cases where it is a lot more work.. (Very contrived) example: PerformSomeAlgorithm(int* piValue) { for(..) { piValue[i] = piValue[i-1]; if(piValue[i]>someConstant) piValue[i]*=2; : : } } Now lets change the function to PerformSomeAlgorithm(float* pfValue)...

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

        Most text editors have a search & replace feature.


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        1 Reply Last reply
        0
        • C Christopher Duncan

          I've noticed that the C# folks at Microsoft have promoted a different naming convention that uses no variable type prefix. At the same time, I've observed that it's now trendy for people to dislike Hungarian notation. When I first started Windows programming Hungarian was indeed strange to get used to. But then, so was the Windows API. However, these days when I look at variable names without it and am left to either guess or search through the code to determine what the variable type is, I find myself thinking that these variable names are only one step removed from the old Basic days of names such as A, B, etc. Why would a straightforward and easy to grasp system of conveying crucial information to the programmer at a glance suddenly become so unpopular? Is there technical reasoning behind it, or is it just a new generation who feels that they must do things differently than those who came before in order to proclaim their identity?

          Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

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

          Christopher Duncan wrote:

          Why would a straightforward and easy to grasp system of conveying crucial information to the programmer at a glance suddenly become so unpopular?

          Any number of reasons. I like it and use it almost exclusively.


          "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

          "Judge not by the eye but by the heart." - Native American Proverb

          N 1 Reply Last reply
          0
          • D David Crow

            Christopher Duncan wrote:

            Why would a straightforward and easy to grasp system of conveying crucial information to the programmer at a glance suddenly become so unpopular?

            Any number of reasons. I like it and use it almost exclusively.


            "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

            "Judge not by the eye but by the heart." - Native American Proverb

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

            DavidCrow wrote:

            I like it and use it almost exclusively.

            In .NET?

            Regards, Nish


            Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
            Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)

            D 1 Reply Last reply
            0
            • N Nish Nishant

              DavidCrow wrote:

              I like it and use it almost exclusively.

              In .NET?

              Regards, Nish


              Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
              Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)

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

              No, .NET and I have yet to cross paths.


              "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

              "Judge not by the eye but by the heart." - Native American Proverb

              N 1 Reply Last reply
              0
              • N Nemanja Trifunovic

                Nishant Sivakumar wrote:

                Maybe : Pen->PutInDrawer() then

                Hehehe, but the pen is not performing the operation either. I would go with something like:

                Nish->Put(pen, drawer);


                Programming Blog utf8-cpp

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

                Yeah, that looks better :-)

                Regards, Nish


                Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)

                1 Reply Last reply
                0
                • D David Crow

                  No, .NET and I have yet to cross paths.


                  "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                  "Judge not by the eye but by the heart." - Native American Proverb

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

                  DavidCrow wrote:

                  No, .NET and I have yet to cross paths.

                  Okay, but Chris D was asking about people using (or not using) Hungarian notation with C#. So I was a bit surprised when you replied saying you use that exclusively :-)

                  Regards, Nish


                  Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                  Currently working on C++/CLI in Action for Manning Publications. (*Sample chapter available online*)

                  1 Reply Last reply
                  0
                  • C Christopher Duncan

                    I've noticed that the C# folks at Microsoft have promoted a different naming convention that uses no variable type prefix. At the same time, I've observed that it's now trendy for people to dislike Hungarian notation. When I first started Windows programming Hungarian was indeed strange to get used to. But then, so was the Windows API. However, these days when I look at variable names without it and am left to either guess or search through the code to determine what the variable type is, I find myself thinking that these variable names are only one step removed from the old Basic days of names such as A, B, etc. Why would a straightforward and easy to grasp system of conveying crucial information to the programmer at a glance suddenly become so unpopular? Is there technical reasoning behind it, or is it just a new generation who feels that they must do things differently than those who came before in order to proclaim their identity?

                    Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

                    M Offline
                    M Offline
                    Michael Dunn
                    wrote on last edited by
                    #38

                    (too lazy to read the whole thread) The problem is that the original purpose of Hungarian was lost. Hungarian should be about showing the purpose of a variable, which is not necessarily its type (as defined by the language). For example, an int or a DWORD could have a prefix of cch to mean "count of characters." This tells you what the variable is for, and doesn't give any indication of its type. What happened later (and I don't know the timeline exactly) is people forgot (or never learned) about the purpose aspect of Hungarian, and thought it was just an indicator of the variable's type. It's this altered Hungarian that people protest against. Original Hungarian, though, is extremely useful in indicating information that the language can't express or verify. A great example is cb versus cch - count of bytes versus count of characters. The distinction is hugely important when dealing with buffers and Unicode strings.

                    --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?

                    1 Reply Last reply
                    0
                    • C Christopher Duncan

                      A reasonable point. However, not everyone writes code in the IDE. In fact, I'm continually surprised that anyone does. :)

                      Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

                      M Offline
                      M Offline
                      Michael P Butler
                      wrote on last edited by
                      #39

                      Christopher Duncan wrote:

                      A reasonable point. However, not everyone writes code in the IDE. In fact, I'm continually surprised that anyone does.

                      I'm surprised. For C# development, the VS2005 IDE can't really be beaten. I certainly wouldn't consider using anything else.

                      Michael CP Blog [^] Development Blog [^]

                      1 Reply Last reply
                      0
                      • C Christopher Duncan

                        I've noticed that the C# folks at Microsoft have promoted a different naming convention that uses no variable type prefix. At the same time, I've observed that it's now trendy for people to dislike Hungarian notation. When I first started Windows programming Hungarian was indeed strange to get used to. But then, so was the Windows API. However, these days when I look at variable names without it and am left to either guess or search through the code to determine what the variable type is, I find myself thinking that these variable names are only one step removed from the old Basic days of names such as A, B, etc. Why would a straightforward and easy to grasp system of conveying crucial information to the programmer at a glance suddenly become so unpopular? Is there technical reasoning behind it, or is it just a new generation who feels that they must do things differently than those who came before in order to proclaim their identity?

                        Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

                        C Offline
                        C Offline
                        Chris Maunder
                        wrote on last edited by
                        #40

                        I think there were licencing issues with using Hungarian so Microsoft had to drop it. I hear they're working on their own version that they'll submit to ECMA.

                        cheers, Chris Maunder

                        CodeProject.com : C++ MVP

                        H C 2 Replies Last reply
                        0
                        • S Shog9 0

                          Christopher Duncan wrote:

                          Why would a straightforward and easy to grasp system of conveying crucial information to the programmer at a glance suddenly become so unpopular?

                          Suddenly? I've hated it since i first saw it - any excuse to ditch it is fine by me... FWIW: the way i heard it explained, The Mad Hungarian originally came up with The Notation as a way to convey meaning as to how the variable would be used. So integers that store coordinates get a different prefix than integers storing measurements which are different than loop counters... This actually makes a bit of sense, if you can be consistent. But the number of times i've seen that done correctly and consistently... well, i could probably count it on the fingers of one foot. Add in all the shitty code out there using incorrect or misleading prefixes, and it becomes an active hindrance. Also, it isn't really Intellisense friendly.

                          ---- Scripts i’ve known... CPhog 1.8.2 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.2 - printer-friendly forums Expand all 1.0 - Expand all messages In-place Delete 1.0 - AJAX-style post delete Syntax 0.1 - Syntax highlighting for code blocks in the forums

                          S Offline
                          S Offline
                          Stuart Dootson
                          wrote on last edited by
                          #41

                          Shog9 wrote:

                          The Mad Hungarian originally came up with The Notation as a way to convey meaning as to how the variable would be used. So integers that store coordinates get a different prefix than integers storing measurements which are different than loop counters...

                          But if you really want to do that, you use a really strongly typed language like Ada (or you could emulate really strong numeric types in C+) and create a new numeric type for each different sort of number. Naming conventions don't work - compiler enforcement will (until people realise casts exist).

                          1 Reply Last reply
                          0
                          • C Chris Maunder

                            I think there were licencing issues with using Hungarian so Microsoft had to drop it. I hear they're working on their own version that they'll submit to ECMA.

                            cheers, Chris Maunder

                            CodeProject.com : C++ MVP

                            H Offline
                            H Offline
                            Hans Dietrich
                            wrote on last edited by
                            #42

                            Chris Maunder wrote:

                            licencing issues with using Hungarian

                            Link?

                            C 1 Reply Last reply
                            0
                            • 1 123 0

                              Nishant Sivakumar wrote:

                              Drawer->PutPen() would be better than both of them Because this doesn't really require a full understanding of English grammar and sentence semantics.

                              I hope you're kidding. First of all, show that statement to any non-programmer and see if they don't think the arrow is backwards. Secondly, remember that millions of English speakers who don't have a "full understanding English grammar and sentence semantics" communicate quite effectively, in English, every day. Natural languages work, even when they're poorly used and/or not fully understood by the speakers. That's why everybody uses them. Even you.

                              D Offline
                              D Offline
                              DavidNohejl
                              wrote on last edited by
                              #43

                              The Grand Negus wrote:

                              Natural languages work, even when they're poorly used and/or not fully understood by the speakers. That's why everybody uses them. Even you.

                              Yes, for a fking human-human communication, but for exact describing of data, algorithms and processes there are better tools, e.g. programming languages.


                              "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

                              1 1 Reply Last reply
                              0
                              • H Hans Dietrich

                                Chris Maunder wrote:

                                licencing issues with using Hungarian

                                Link?

                                C Offline
                                C Offline
                                Chris Maunder
                                wrote on last edited by
                                #44

                                Notice the joke icon next to my post? ;)

                                cheers, Chris Maunder

                                CodeProject.com : C++ MVP

                                1 Reply Last reply
                                0
                                • D DavidNohejl

                                  The Grand Negus wrote:

                                  Natural languages work, even when they're poorly used and/or not fully understood by the speakers. That's why everybody uses them. Even you.

                                  Yes, for a fking human-human communication, but for exact describing of data, algorithms and processes there are better tools, e.g. programming languages.


                                  "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

                                  1 Offline
                                  1 Offline
                                  123 0
                                  wrote on last edited by
                                  #45

                                  dnh wrote:

                                  Yes, for a fking human-human communication, but for exact describing of data, algorithms and processes there are better tools, e.g. programming languages.

                                  We disagree. And we're qualified to comment on the matter because we have described the data, algorithms and processes necessary for a significantly broad and deep application, a complete development system - including unique interface, simplified file manager, hexadecimal dumper, elegant text editor, wysiwyg page editor, and native-code generating compiler - conveniently and efficiently using nothing but Plain English. So until you've done the equivalent, both ways, as we have, perhaps it would be wiser for you to simply withhold judgment.

                                  D 1 Reply Last reply
                                  0
                                  • C Chris Maunder

                                    I think there were licencing issues with using Hungarian so Microsoft had to drop it. I hear they're working on their own version that they'll submit to ECMA.

                                    cheers, Chris Maunder

                                    CodeProject.com : C++ MVP

                                    C Offline
                                    C Offline
                                    Christopher Duncan
                                    wrote on last edited by
                                    #46

                                    :laugh:

                                    Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

                                    1 Reply Last reply
                                    0
                                    • C Christopher Duncan

                                      I've noticed that the C# folks at Microsoft have promoted a different naming convention that uses no variable type prefix. At the same time, I've observed that it's now trendy for people to dislike Hungarian notation. When I first started Windows programming Hungarian was indeed strange to get used to. But then, so was the Windows API. However, these days when I look at variable names without it and am left to either guess or search through the code to determine what the variable type is, I find myself thinking that these variable names are only one step removed from the old Basic days of names such as A, B, etc. Why would a straightforward and easy to grasp system of conveying crucial information to the programmer at a glance suddenly become so unpopular? Is there technical reasoning behind it, or is it just a new generation who feels that they must do things differently than those who came before in order to proclaim their identity?

                                      Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

                                      T Offline
                                      T Offline
                                      Tim Craig
                                      wrote on last edited by
                                      #47

                                      Christopher Duncan wrote:

                                      I've noticed that the C# folks at Microsoft have promoted a different naming convention that uses no variable type prefix. At the same time, I've observed that it's now trendy for people to dislike Hungarian notation.

                                      Did you notice that while they were at it, the C# folks now force their idea of how the curly braces are to be indented? Visual Studio doesn't offer a choice like when the project is C++.

                                      The evolution of the human genome is too important to be left to chance idiots like CSS.

                                      1 Reply Last reply
                                      0
                                      • C Christopher Duncan

                                        A reasonable point. However, not everyone writes code in the IDE. In fact, I'm continually surprised that anyone does. :)

                                        Author of The Career Programmer and Unite the Tribes www.PracticalStrategyConsulting.com

                                        R Offline
                                        R Offline
                                        Rohde
                                        wrote on last edited by
                                        #48

                                        Please tell me why that's surprising for you. I simply don't understand it. :-D What does a normal text editor gives you that VS doesn't? If you don't use any of the bells and whistles of the IDE that's fine, but surely it doesn't provide anything less than any normal editor, so why not just use the IDE as an editor with built-in compiler? Granted VS sucks for C++, but for C# it's really really good.


                                        "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
                                        -Atlas Shrugged, Ayn Rand

                                        1 Reply Last reply
                                        0
                                        • 1 123 0

                                          dnh wrote:

                                          Yes, for a fking human-human communication, but for exact describing of data, algorithms and processes there are better tools, e.g. programming languages.

                                          We disagree. And we're qualified to comment on the matter because we have described the data, algorithms and processes necessary for a significantly broad and deep application, a complete development system - including unique interface, simplified file manager, hexadecimal dumper, elegant text editor, wysiwyg page editor, and native-code generating compiler - conveniently and efficiently using nothing but Plain English. So until you've done the equivalent, both ways, as we have, perhaps it would be wiser for you to simply withhold judgment.

                                          D Offline
                                          D Offline
                                          DavidNohejl
                                          wrote on last edited by
                                          #49

                                          The Grand Negus wrote:

                                          So until you've done the equivalent, both ways, as we have, perhaps it would be wiser for you to simply withhold judgment.

                                          Do you think I never used natural language to describe algorithm?! :mad: While convenience is subjective, I think that thousands of thousands scientist etc who developed and used formal languages for hundreds of years agree with me. Yes, one *can* program using plain English. But it sucks. Only use I can see is to allow people without formal education to program. Wow that's cool. Not.


                                          "Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus

                                          1 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