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 in .Net - Yes or No?

Hungarian Notation in .Net - Yes or No?

Scheduled Pinned Locked Moved The Lounge
csharpc++rubybeta-testingtools
90 Posts 42 Posters 9 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.
  • B Brady Kelly

    Judah Himango wrote:

    I've been doing that now as well. isFooEnabled, isDisplayingBars, etc.

    Opens up a whole new kettle of questions (I'm mixing what?). I often, late at night, get strung out over, 'isForExport', or 'mustExport', or 'useAltExport', or 'isToUseAltExport'.

    S Offline
    S Offline
    Shog9 0
    wrote on last edited by
    #76

    Here's the trick: read the code out loud: if it comes out sounding like a bad foreign accent (or, Yoda), then you need to work on the names... ;)

    ----

    I don't care what you consider witty, but at least I do not blather on posting nonsense like Jim Crafton.

    -- Stringcheese, humbled by Crafton's ability to string together multiple sentences

    J S 2 Replies Last reply
    0
    • V Vikram A Punathambekar

      :) I too went to .NET from a Win32/MFC background, and found it strange - userName instead of strUserName felt awkward at first, but now it's the other way round. Besides, if you were to continue using Hungarian, your variable names would clash savagely with the framework's names (and others' ;) ). I'll tell you what I do not like about the .NET naming conventions, though - I think camelCase is way better for method names. [ducks]

      John Simmons / outlaw programmer wrote:

      the ORCAS Beta 2 is so transiently reliable

      I'd never install MS (or for that matter, most) betas. Unless the client wanted something to be oh-so-ready for the future.

      Cheers, Vıkram.


      After all is said and done, much is said and little is done.

      D Offline
      D Offline
      David Stone
      wrote on last edited by
      #77

      Vikram A Punathambekar wrote:

      I think camelCase is way better for method names. [ducks]

      Actually, after having spent so much time in Java over the past few quarters at school, camelCase method names feel more natural for me. I still have to think about it when I'm writing C# again.

      V 1 Reply Last reply
      0
      • B Brady Kelly

        Nemanja Trifunovic wrote:

        brain-damaged .NET 1.x collections

        What do you mean by that? The non-generic ones?

        D Offline
        D Offline
        David Stone
        wrote on last edited by
        #78

        Yes. Using non-generic collections is a horrific practice in any application that has access to the generic ones.

        S 1 Reply Last reply
        0
        • P Paul Conrad

          Chris Maunder wrote:

          hungarian notation

          Now that's a notation I have not used in a long, long, long time :)

          "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

          S Offline
          S Offline
          StevenWalsh
          wrote on last edited by
          #79

          Paul Conrad wrote:

          Now that's a notation I have not used in a long, long, long time

          I Float between the two, but i've lately i've been trying to double my use of hungarian notation ;)

          P 1 Reply Last reply
          0
          • S Shog9 0

            Here's the trick: read the code out loud: if it comes out sounding like a bad foreign accent (or, Yoda), then you need to work on the names... ;)

            ----

            I don't care what you consider witty, but at least I do not blather on posting nonsense like Jim Crafton.

            -- Stringcheese, humbled by Crafton's ability to string together multiple sentences

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

            :laugh: Seriously though, that's a great argument for fluent interfaces[^].

            Tech, life, family, faith: Give me a visit. I'm currently blogging about: Orthodox Jews are persecuting Messianic Jews in Israel (video) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

            1 Reply Last reply
            0
            • V Vikram A Punathambekar

              :) I too went to .NET from a Win32/MFC background, and found it strange - userName instead of strUserName felt awkward at first, but now it's the other way round. Besides, if you were to continue using Hungarian, your variable names would clash savagely with the framework's names (and others' ;) ). I'll tell you what I do not like about the .NET naming conventions, though - I think camelCase is way better for method names. [ducks]

              John Simmons / outlaw programmer wrote:

              the ORCAS Beta 2 is so transiently reliable

              I'd never install MS (or for that matter, most) betas. Unless the client wanted something to be oh-so-ready for the future.

              Cheers, Vıkram.


              After all is said and done, much is said and little is done.

              R Offline
              R Offline
              Rocky Moore
              wrote on last edited by
              #81

              Vikram A Punathambekar wrote:

              I'll tell you what I do not like about the .NET naming conventions

              The one thing I do not like about .NET naming conventions is VB and any other case insensitive langauges forcing those bloddy "_" underscores on us again. I think that key needs to be removed from everyone's keyboard! :)

              Rocky <>< Latest Code Blog Post: www.TheWPFDirectory.com site launched! Latest Tech Blog Post: You got to see this - Seadragon and Photosynth!

              1 Reply Last reply
              0
              • J Judah Gabriel Himango

                I don't mind Hungarian notation (the false kind that's practiced now, or the original kind[^]), which, ironically for you, was invented by a Microsoft programmer. Personally, once I started coding in C#, I abandoned all Hungarian notation and found it quite liberating. It now seems superfluous to put a character at the beginning of each variable just to define the type. Simply put, I've never once thought to myself, "gee, is it a boolean? Or a string?"

                Tech, life, family, faith: Give me a visit. I'm currently blogging about: Orthodox Jews are persecuting Messianic Jews in Israel (video) The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

                R Offline
                R Offline
                Rocky Moore
                wrote on last edited by
                #82

                Yeah, I agree. Funny though, when it comes to bool's I never thought I could survive without bMailWaiting or bPosts, but after .NET it seems much clearer with isMailWaiting or hasPosts... :) Oh yeah, I almost forgot, now about every method that returns a status bool for failure, now my local variable inside the method is usually "isOkay" ;) Okay, it could be "bIsOkay", but that just doesn't sound right :)

                Rocky <>< Latest Code Blog Post: www.TheWPFDirectory.com site launched! Latest Tech Blog Post: You got to see this - Seadragon and Photosynth!

                1 Reply Last reply
                0
                • S StevenWalsh

                  Paul Conrad wrote:

                  Now that's a notation I have not used in a long, long, long time

                  I Float between the two, but i've lately i've been trying to double my use of hungarian notation ;)

                  P Offline
                  P Offline
                  Paul Conrad
                  wrote on last edited by
                  #83

                  Sometimes I'll do Hungarian out of shear laziness :->

                  "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                  1 Reply Last reply
                  0
                  • realJSOPR realJSOP

                    I recently posted a C# article and as a C++ programmer is wont to do, I used hungarian notation on all my variables. This has generated a bit of discussion in the comments for the article, and not wanting to be completely close-minded about it, I decided to google it. Here's what I've found so far: 0) It seems that Microsoft thinks we should abandon it in favor of "more natural english-like" variable names. The best response to that statement was this little gem: "If Microsoft said I shouldn't comment my code, it wouldn't stop me from doing that, either." I could not have said it better myself. Maybe this outlook by Microsoft is why Vista is such garbage, or why the ORCAS Beta 2 is so transiently reliable. Just because some self-important evangelist from Microsoft says it doesn't make it gold. Translation - this claim is pretty weak. This is from Microsoft's coding guidelines: Use names that describe a parameter's meaning rather than names that describe a parameter's type. Development tools should provide meaningful information about a parameter's type. Therefore, a parameter's name can be put to better use by describing meaning. Use type-based parameter names sparingly and only where it is appropriate. It looks to me like they're putting the emphasis on reading code squarely on the end user instead of the developer. Hello!? We're programmers, and we can't be bothered by trying to figure out what type a variable is supposed to be. Sure, code should be easy to read, but that trait is introduced with meaningful variable and function names, not by removing ancillary information about the variables being used. 1) If you change the variable's type, it all of a sudden invalidates the name of the variable. Ever heard of Find/replace (with case matching and whole word turned on)? Besides, I can count on one hand how many times I changed the type of a variable in the last 18 years of C++ work. 2) Puts an emphasis on the type instead of the descriptive identifier name—encourages poor variable names. Ummm, how can a single lowercase character move the emphasis from the following variable name to the type itself. Further, hungarian notation in no way promotes the creation of "poor variable names". I can't recall ever hearing a programmer say, "Yep, using hungarian notation so that means I can skimp on the rest of the variable name." There are other equally invalid reasons put forth by all manner of know-it-alls, but I got bored typing this stuff. ------

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

                    John Simmons / outlaw programmer wrote:

                    If you change the variable's type, it all of a sudden invalidates the name of the variable.

                    This is a Good Thing. If you change the type of a variable, it's a good idea to look at every place the variable is used, to make sure the code using it is still correct.

                    --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

                    1 Reply Last reply
                    0
                    • realJSOPR realJSOP

                      I recently posted a C# article and as a C++ programmer is wont to do, I used hungarian notation on all my variables. This has generated a bit of discussion in the comments for the article, and not wanting to be completely close-minded about it, I decided to google it. Here's what I've found so far: 0) It seems that Microsoft thinks we should abandon it in favor of "more natural english-like" variable names. The best response to that statement was this little gem: "If Microsoft said I shouldn't comment my code, it wouldn't stop me from doing that, either." I could not have said it better myself. Maybe this outlook by Microsoft is why Vista is such garbage, or why the ORCAS Beta 2 is so transiently reliable. Just because some self-important evangelist from Microsoft says it doesn't make it gold. Translation - this claim is pretty weak. This is from Microsoft's coding guidelines: Use names that describe a parameter's meaning rather than names that describe a parameter's type. Development tools should provide meaningful information about a parameter's type. Therefore, a parameter's name can be put to better use by describing meaning. Use type-based parameter names sparingly and only where it is appropriate. It looks to me like they're putting the emphasis on reading code squarely on the end user instead of the developer. Hello!? We're programmers, and we can't be bothered by trying to figure out what type a variable is supposed to be. Sure, code should be easy to read, but that trait is introduced with meaningful variable and function names, not by removing ancillary information about the variables being used. 1) If you change the variable's type, it all of a sudden invalidates the name of the variable. Ever heard of Find/replace (with case matching and whole word turned on)? Besides, I can count on one hand how many times I changed the type of a variable in the last 18 years of C++ work. 2) Puts an emphasis on the type instead of the descriptive identifier name—encourages poor variable names. Ummm, how can a single lowercase character move the emphasis from the following variable name to the type itself. Further, hungarian notation in no way promotes the creation of "poor variable names". I can't recall ever hearing a programmer say, "Yep, using hungarian notation so that means I can skimp on the rest of the variable name." There are other equally invalid reasons put forth by all manner of know-it-alls, but I got bored typing this stuff. ------

                      P Offline
                      P Offline
                      PaulPrice
                      wrote on last edited by
                      #85

                      As mentioned at some point in this thread, a decent IDE will tell you a type anyway so you do not need to include this information in the variable name. Also I tend to find that if all variable names look the same, for example start with str or mint then I struggle to read the code.

                      1 Reply Last reply
                      0
                      • D David Stone

                        Yes. Using non-generic collections is a horrific practice in any application that has access to the generic ones.

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

                        Quite right - after having used C++/STL for more years than I care to remember, I was unwilling to look at .NET at all until 2.0. And with lambdas and Linq in 3.0, C# is looking pretty good...

                        1 Reply Last reply
                        0
                        • S Shog9 0

                          Here's the trick: read the code out loud: if it comes out sounding like a bad foreign accent (or, Yoda), then you need to work on the names... ;)

                          ----

                          I don't care what you consider witty, but at least I do not blather on posting nonsense like Jim Crafton.

                          -- Stringcheese, humbled by Crafton's ability to string together multiple sentences

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

                          Careful - too far down that road and you'll turn into the Grand Magus :-)

                          1 Reply Last reply
                          0
                          • D David Stone

                            Vikram A Punathambekar wrote:

                            I think camelCase is way better for method names. [ducks]

                            Actually, after having spent so much time in Java over the past few quarters at school, camelCase method names feel more natural for me. I still have to think about it when I'm writing C# again.

                            V Offline
                            V Offline
                            Vikram A Punathambekar
                            wrote on last edited by
                            #88

                            I *have* done some Java, but it wasn't a big deal - one paper at college and one Java app maintenance at my previous company. I've written FAR more C# code than Java, but for some strange reason, camelCase feels more natural for method names. I actually dislike PascalCase for method names!

                            Cheers, Vıkram.


                            After all is said and done, much is said and little is done.

                            1 Reply Last reply
                            0
                            • M Miszou

                              Whereabouts in the Midwest are you, Limey? I've been a Limey in Central California for almost 9 years now...


                              Sunrise Wallpaper Project | The StartPage Randomizer | A Random Web Page

                              M Offline
                              M Offline
                              MidwestLimey
                              wrote on last edited by
                              #89

                              Ol' St louie, gateway to the west


                              I'm largely language agnostic


                              After a while they all bug me :doh:


                              1 Reply Last reply
                              0
                              • T ToddHileHoffer

                                I might be in minority but I don't really care. If you are using VS2005 Hungarian notation adds little value. Just put the cursor over the object and the type is displayed. Honestly I'm not consistent with my naming. I might have a text box name txtBox1, txtName, txt or just "x" (if I'm using it in a loop). Since I do ASP.Net I don't have to many 10,000 line methods because all the code has to run during a postback. I'm the same way with my database fieldnames, I just don't care. You may call it laziness but I think too many programmers an Anal about this stuff. Like I said before, if I want to know what type something is, I just put the cursor on it.

                                I didn't get any requirements for the signature

                                M Offline
                                M Offline
                                MidwestLimey
                                wrote on last edited by
                                #90

                                You should have worked on an ASP.Net project I walked into a few years back. Every page had a 1k-2k page load routine (80% of which had the same functionality) and then 200+ lines in every event handler. The average page size was 3k+ lines. All with the most brutal hungarian standards I'd ever seen. It was utterly unreadable and un-maintainable, and coded accord to the strictest standards (that I ignored)!


                                I'm largely language agnostic


                                After a while they all bug me :doh:


                                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