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 vs. IntelliSense

Hungarian Notation vs. IntelliSense

Scheduled Pinned Locked Moved The Lounge
c++visual-studioalgorithmsquestion
33 Posts 21 Posters 3 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.
  • A Andrew Peace

    All true. I don't use Visual Assist (shame on me, I know), but I do use the 'p', 'm_', 'g_', 'n', 'sz' prefixes. Unlike some of the sxuggestions in the guide to Hungarian Notation in MSDN I don't absolutely mad and notate absolutely everything about a variable. > Andrew.

    J Offline
    J Offline
    James Pullicino
    wrote on last edited by
    #17

    Same here.

    1 Reply Last reply
    0
    • J Jonathan Gilligan

      Aside from Hungarian (I do like the m_ notation), I like to name parameters with a trailing underscore.

      void MyClass::BigFunction(int nValue_)
      {
      // ... reams of code
      m_nValue = nValue_; // trailing '_' helps me remember that
      // nValue_ is a parameter, not a local
      // variable.
      }

      J Offline
      J Offline
      James Pullicino
      wrote on last edited by
      #18

      Parameters are local variables.

      J 1 Reply Last reply
      0
      • H Henry Jacobs

        The purpose of Hungarian notation is to include the variable's type in its name so programmers know the type whenever the variable is used. Have any of you using Visual C++ 6 hovered the cursor over a variable? Henry casually scans the room searching a fire extinguisher.

        S Offline
        S Offline
        Simon Brown
        wrote on last edited by
        #19

        Hi, Some of us have to compile our C++ code on: Windows, UNIX, VMS, AS400, Tandem and MVS. And my mouse don't fly ;) Old Simon

        1 Reply Last reply
        0
        • C Christian Graus

          I used to love Hungarian notation, but the MSDN is proof of it's inadequacies. How many basic types have changed ( wParam for example ) and now have names that imply they are something they are not ? I always use p for a pointer, otherwise I find it to be of no value. Visual Assist tells me what type a variable is anyhow, and I have no use for looking over source code on paper, where I cannot edit it if I want to. Christian #include "std_disclaimer.h" People who love sausage and respect the law should never watch either one being made. The things that come to those who wait are usually the things left by those who got there first.

          S Offline
          S Offline
          Simon Brown
          wrote on last edited by
          #20

          Some of the worst C++ I have seen is in the MFC source and to a lesser extent on MSDN, but to be fair quite a lot of it is quite old. Then again, if you want poor code just look at SAP (on second thoughts, better not - it's very depressing). Old Simon

          1 Reply Last reply
          0
          • P Pavlos Touboulidis

            ... And of course, it's even harder to use this->nValue = nValue; ;) I personally don't like Hungarian Notation, but it's almost a standard in Win32 programming. What I hate the most is the Win32 typedefs like: LPCTSTR, LPTSTR, LPxxx etc. X|

            S Offline
            S Offline
            Simon Brown
            wrote on last edited by
            #21

            What I hate the most is the Win32 typedefs like: LPCTSTR, LPTSTR, LPxxx etc. Why? They are obvious? Old Simon

            S 1 Reply Last reply
            0
            • T Tim Deveaux

              I think Mike Dunn wrote a shell extension for that. :-D

              A Offline
              A Offline
              Anna Jayne Metcalfe
              wrote on last edited by
              #22

              What more can I say but... ROFL! ;P Andy Metcalfe - Sonardyne International Ltd
              (andy.metcalfe@lineone.net)
              http://www.resorg.co.uk

              "I used to be a medieval re-enactor, but I'm (nearly) alright now..."

              1 Reply Last reply
              0
              • S Simon Brown

                What I hate the most is the Win32 typedefs like: LPCTSTR, LPTSTR, LPxxx etc. Why? They are obvious? Old Simon

                S Offline
                S Offline
                Simon Capewell
                wrote on last edited by
                #23

                The L is the annoying bit for me, since it's a legacy thing from 16 bit days. Of cource you could argue that it'll have a second wind with win64...

                A 1 Reply Last reply
                0
                • S Simon Capewell

                  The L is the annoying bit for me, since it's a legacy thing from 16 bit days. Of cource you could argue that it'll have a second wind with win64...

                  A Offline
                  A Offline
                  Anna Jayne Metcalfe
                  wrote on last edited by
                  #24

                  I dropped the "l" prefix when I started with VC 4.0. Most of the others still make sense though I do get irritated that Win32 and MFC use different prefixes! Andy Metcalfe - Sonardyne International Ltd
                  (andy.metcalfe@lineone.net)
                  http://www.resorg.co.uk

                  "I used to be a medieval re-enactor, but I'm (nearly) alright now..."

                  1 Reply Last reply
                  0
                  • H Henry Jacobs

                    Are you using PAPER.NET? ;)

                    J Offline
                    J Offline
                    jkgh
                    wrote on last edited by
                    #25

                    .. Paper - how quaint! ATL Student :rolleyes:

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      One reason I use the "m_":

                      void MyClass::SetValue(int nValue)
                      {
                      m_nValue = nValue;
                      }

                      If I didn't use the 'm_' I'd have to think of different names for the member variable and the parameter. WAY too hard ;) cheers, Chris Maunder

                      M Offline
                      M Offline
                      Martin Bohring
                      wrote on last edited by
                      #26

                      Hello Chris, what about this.nValue = nValue :)

                      M 1 Reply Last reply
                      0
                      • M Martin Bohring

                        Hello Chris, what about this.nValue = nValue :)

                        M Offline
                        M Offline
                        Martin Bohring
                        wrote on last edited by
                        #27

                        Uh Oh, should have been this->nValue = nValue:| :|

                        A 1 Reply Last reply
                        0
                        • C Christian Graus

                          Sounds like you're taking a sensible approach - doing it when it makes sense instead of because it's the 'done thing'. Christian #include "std_disclaimer.h" People who love sausage and respect the law should never watch either one being made. The things that come to those who wait are usually the things left by those who got there first.

                          T Offline
                          T Offline
                          Tim Smith
                          wrote on last edited by
                          #28

                          Yeah, same with me. I use Hungarian notation as a tool, not a religion. I have looked at some of my old code with H-N and some of my old code without it. I was able work with the H-N code faster and get my job done faster. So I use it. It is simple as that. Tim Smith Descartes Systems Sciences, Inc.

                          1 Reply Last reply
                          0
                          • J Jonathan Gilligan

                            One more aspect of naming, it's easy to look at lists of names (for instance in a .map file or dumpbin output) and tell what's what. You can always use UndecorateName() to get some of this information but it's incomplete and inconvenient. It's good to be able to grep through code and such for global variables, member attributes, functions, local variables, function arguments, etc. Thus, I get most mileage from the stuff before the underscore (I use m_, s_ (static member), g_ (global), sc_ (static const member), gc_ (const global), and (rarely) mc_ (const member)). I have gotten in the habit of using Hungarian everywhere because it helped me out when I was first writing Windows code, but it is much less useful to me now. More of a bad habit that I haven't broken or learned to moderate (is there a local chapter of Hungarians Anonymous in Tennessee? :-)).

                            H Offline
                            H Offline
                            Henry Jacobs
                            wrote on last edited by
                            #29

                            I also used HN when I started programming Windows but have since stopped. I still use g_ and m_ though.

                            1 Reply Last reply
                            0
                            • M Martin Bohring

                              Uh Oh, should have been this->nValue = nValue:| :|

                              A Offline
                              A Offline
                              Anna Jayne Metcalfe
                              wrote on last edited by
                              #30

                              I really don't like this particular style. I just don't find it clear. One of our (former) developers used to use this->SomeFunction() to force Intellisense to display the members of the class while he was coding (he hadn't discovered CTRL+SPACE). Everybody on the team used to hate reading his code. Just one of them things I guess - in his own words "much badness" X| Andy Metcalfe - Sonardyne International Ltd
                              (andy.metcalfe@lineone.net)
                              http://www.resorg.co.uk

                              "I used to be a medieval re-enactor, but I'm (nearly) alright now..."

                              1 Reply Last reply
                              0
                              • C Chris Losinger

                                IntelliSense only works about 50% of the time for me. the other 50% it's either wrong or unresponsive. So, it's essentially useless since you don't know if you've mispelled a variable name or if IntelliSense is just sleeping again. Hungarian should be the 11th Commandment: In statically typed languages, thou shalt use a name that describes the variable's type. -c ------------------------------ Smaller Animals Software, Inc. http://www.smalleranimals.com

                                J Offline
                                J Offline
                                John M Drescher
                                wrote on last edited by
                                #31

                                I agree.. And Command Completion via ctrl-space works about 20% of the time. It seems to never know the scope of the variables I'm using because It appears to be doing preprocessing (checking the syntax) and of course while I'm typing a statement and it is not complete it is a syntax error... And for Intellisense, I experience the same unresponsive behavior, its not the speed of my pc. My primary development machine is a new 900 Mhz Athlon Win2k box with 512MB of memory and 45GB of harddisk space with 20GB free. John

                                J 1 Reply Last reply
                                0
                                • J John M Drescher

                                  I agree.. And Command Completion via ctrl-space works about 20% of the time. It seems to never know the scope of the variables I'm using because It appears to be doing preprocessing (checking the syntax) and of course while I'm typing a statement and it is not complete it is a syntax error... And for Intellisense, I experience the same unresponsive behavior, its not the speed of my pc. My primary development machine is a new 900 Mhz Athlon Win2k box with 512MB of memory and 45GB of harddisk space with 20GB free. John

                                  J Offline
                                  J Offline
                                  John Fisher
                                  wrote on last edited by
                                  #32

                                  This is why I use VisualAssist. John

                                  1 Reply Last reply
                                  0
                                  • J James Pullicino

                                    Parameters are local variables.

                                    J Offline
                                    J Offline
                                    Jonathan Gilligan
                                    wrote on last edited by
                                    #33

                                    Parameters are local variables. Not in all respects. When a parameter is passed by reference, there are side effects to assigning to it. I need to worry about whether auto variables within a function have been initialized, but I can assume that a parameter has been initialized. When a pointer is passed in, I want to treat it differently than if I have assigned it locally. For all of these reasons, it's helpful to me to keep the two kinds of variables straight in my mind and I find it useful to make them lexicographically distinct. I understand that not everyone may find this useful. That's fine.

                                    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