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. What do you think?

What do you think?

Scheduled Pinned Locked Moved The Lounge
questiondatabasesql-servercomsysadmin
94 Posts 67 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.
  • R Rocky Moore

    Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

    Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

    D Offline
    D Offline
    drdavef
    wrote on last edited by
    #54

    I used the m prefix when using VB6. Now with VS2005, I much prefer the _ and have also stoped using str, int, prefixes also. Much more like the Java mode for naming object. David

    1 Reply Last reply
    0
    • R Rocky Moore

      Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

      Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

      E Offline
      E Offline
      ednrgc
      wrote on last edited by
      #55

      I usually name the private member in lowercase, and the Properties to access them in CamelCase.

      1 Reply Last reply
      0
      • A Aaron VanWieren

        Mohamed A. Meligy wrote:

        class library developer guidance.

        Just curious, but do you have a link for this. Whenever I look for this, I find a gazillion different styles being used in Microsoft example code.

        R Offline
        R Offline
        R Ziak
        wrote on last edited by
        #56

        Search MSDN for naming conventions.

        1 Reply Last reply
        0
        • R Rocky Moore

          Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

          Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

          M Offline
          M Offline
          MSBassSinger
          wrote on last edited by
          #57

          >Do you use/like the "_" to prefix private members? My habit is to use m_ for module level variables. I never make them public. If I want to expose its value, I use a property to get or set it. I use no prefix for variables whose scope is within the method. I also use a 3 letter prefix for the data type, e.g. strName, m_lngCount, etc. It is not the only way, but it is a way I like, it is readable, and I see no reason to change. I never saw a reason to simply use a "_". I remember the days when processor cycles and memory (RAM and disk) were at such a premium that code was cryptic. Those days have been gone for decades, so I saw no reason not to use more human readable names. JD Waleska, GA

          1 Reply Last reply
          0
          • P Phil Harding

            Rocky Moore wrote:

            Do you use/like the "_" to prefix private members

            Firmly in the "m_" camp for class attributes (member variables is sooo last season) :)

            Phil Harding.
            myBlog [^] | mySite [^]

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

            We call' em fields.


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

            P 1 Reply Last reply
            0
            • D DavidNohejl

              We call' em fields.


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

              P Offline
              P Offline
              Phil Harding
              wrote on last edited by
              #59

              dnh wrote:

              We call' em fields

              Luddite :)

              Phil Harding.
              myBlog [^] | mySite [^]

              D 1 Reply Last reply
              0
              • R Rocky Moore

                Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

                Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

                M Offline
                M Offline
                Member 96
                wrote on last edited by
                #60

                It took me a *long* time to break that habit when I moved to c#.

                R 1 Reply Last reply
                0
                • R Rocky Moore

                  Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

                  Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

                  S Offline
                  S Offline
                  sstring
                  wrote on last edited by
                  #61

                  For those who are interested, I created a poll to settle this once and for all (:laugh:). Variable Naming Conventions Poll[^] BTW: The site is new - Any feed back would be greatly appreciated. Thanks! Steve

                  1 Reply Last reply
                  0
                  • R Rocky Moore

                    Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

                    Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

                    T Offline
                    T Offline
                    the real r2d2
                    wrote on last edited by
                    #62

                    For members: itsDoc For arguements: theDoc For locals: aOK = false; while( ! aOK ) { : : aOK = true; } return aOK;

                    Beware of programmers who carry screwdrivers - XTalk

                    R 1 Reply Last reply
                    0
                    • A Aaron VanWieren

                      Can't stand _them. Sorry to butt in on this, but this is one thing I truly hate. Isn't this part of or all of the Hungarian notation? Which has historical roots in early programming?

                      A Offline
                      A Offline
                      AccorTracy
                      wrote on last edited by
                      #63

                      Can't stand them either. Half the time I'll fat-finger it and type ")" or "+", which means I have to stop and fix it, or look down at the keyboard to make sure my ring-finger is hitting the right key.

                      1 Reply Last reply
                      0
                      • R Rocky Moore

                        Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

                        Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

                        J Offline
                        J Offline
                        Jasmine2501
                        wrote on last edited by
                        #64

                        No. I reject such nonsense. When you say: private int NumberOfWheels; ...that makes it pretty clear. I reject comments, prefixes, and anything besides the above to define a variable. Everything you need to know about it is in the definition. I would also avoid basing any decisions on Microsoft sample code.

                        "Quality Software since 1983!"
                        http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.

                        M 1 Reply Last reply
                        0
                        • R Rocky Moore

                          Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

                          Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

                          K Offline
                          K Offline
                          kgwalke
                          wrote on last edited by
                          #65

                          I am not sure what language(s) you are talking about. However, the C++ standard reserves identifiers beginning with the underscore character[17.4.3.1.2]: "Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace". Some current styles recommend using a trailing underscore instead, as in private_.

                          1 Reply Last reply
                          0
                          • J Jasmine2501

                            No. I reject such nonsense. When you say: private int NumberOfWheels; ...that makes it pretty clear. I reject comments, prefixes, and anything besides the above to define a variable. Everything you need to know about it is in the definition. I would also avoid basing any decisions on Microsoft sample code.

                            "Quality Software since 1983!"
                            http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.

                            M Offline
                            M Offline
                            MSBassSinger
                            wrote on last edited by
                            #66

                            It's OK with me if you reject it. I prefer my code to be readable by others. I program in VB6, VB.NET, and C#, depending on who I am programming for. The declaration of a variable is not the only place one see it. If somewhere in the code the reader comes across "NameID", I would like them to know if it is local or module level, if it is int16, int32, or int64. Chances are, someone else will have to support my code at sometime. The easier it is for them to understand it, the better off he and I are. JD Waleska, GA

                            J 1 Reply Last reply
                            0
                            • M MSBassSinger

                              It's OK with me if you reject it. I prefer my code to be readable by others. I program in VB6, VB.NET, and C#, depending on who I am programming for. The declaration of a variable is not the only place one see it. If somewhere in the code the reader comes across "NameID", I would like them to know if it is local or module level, if it is int16, int32, or int64. Chances are, someone else will have to support my code at sometime. The easier it is for them to understand it, the better off he and I are. JD Waleska, GA

                              J Offline
                              J Offline
                              Jasmine2501
                              wrote on last edited by
                              #67

                              I knew someone would mention that, but I didn't bother to head it off at the pass because I figured one would realize that with modern programming tools, that is no longer an issue. The definition of the thing is always available, and even if you're 500 lines away from it, you can always find it easily. Historically, I realize the purpose of hungarian-style notations in the variable name, but modern tools are making that notion obsolete and I prefer not to bog down my code with unnecessary stuff. Programmers coming along later won't have any confusion no matter what notations they are familiar with. If they can't read the variable definition, then they probably shouldn't be writing code in the first place.

                              "Quality Software since 1983!"
                              http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.

                              M 1 Reply Last reply
                              0
                              • J Jasmine2501

                                I knew someone would mention that, but I didn't bother to head it off at the pass because I figured one would realize that with modern programming tools, that is no longer an issue. The definition of the thing is always available, and even if you're 500 lines away from it, you can always find it easily. Historically, I realize the purpose of hungarian-style notations in the variable name, but modern tools are making that notion obsolete and I prefer not to bog down my code with unnecessary stuff. Programmers coming along later won't have any confusion no matter what notations they are familiar with. If they can't read the variable definition, then they probably shouldn't be writing code in the first place.

                                "Quality Software since 1983!"
                                http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles.

                                M Offline
                                M Offline
                                MSBassSinger
                                wrote on last edited by
                                #68

                                Sorry, but I don't take such an elitist view. I am all for new programmers learning, and code excerpts may not always be in the IDE. In addition, code tends to live a long time. You can't always count on the IDE being effective. Look at how MS screwed up the IDE from VB6 to VB.NET. After over 6 years of working with .NET, the IDE is starting to get back to being as useful as it was in 1998. I think how you notate your variables is perfectly fine. I choose to do mine the way I do for specific reasons. I am not likely to change just because Microsoft says so. JD Waleska, GA

                                J 1 Reply Last reply
                                0
                                • J Jon W

                                  I Like them! :rose: Why? I'm a VB.NET developer... to write none language dependent code is like coding to interfaces instead of implementations ;P What do I mean? Well to easily convert / write / use code from BOTH c# and VB.Net "_" simplifies a great bit... Mainly because vb.net is not case sensitive. I find the "_" char the least disturbing in reading / skimming through code. The m_ prefix i dislike the m_ prefix as I consider it outdated; as far as I know the m stands for member, and if I want to now a class member I take a look in the Object browser, or use the "Me" (this in c#) ex: Me._myFieldName therefore in my opinion -> m_ adds "nothing". As the previous post states, the _ is used for private members and therefore encapsulated by the class and you work with the public properties / methods instead i.o.w not that big of a problem (in my humble opinion) in contrast to language independence.

                                  I Offline
                                  I Offline
                                  in9mar
                                  wrote on last edited by
                                  #69

                                  I like _them as well. The best way to differentiate easily between local variables and class variables. Combined with NOT having any public class variables this makes code very readable. Decrease in readability would only come from m_ . So that one I do not recommend. :)

                                  1 Reply Last reply
                                  0
                                  • N neffc

                                    I am very agreeable with the underscore since it takes advantage of Intellisense for seeing my private/protected fields quickly. It should not matter what you name a field because it should always be accessed through a property. What I would like to hear some opinions on is the naming of User Interface controls such that I don't want my default event handlers looking really crazy i.e. do you: btnValidate buttonValidate validateButton (something else) cneff78

                                    I Offline
                                    I Offline
                                    ITGFanatic
                                    wrote on last edited by
                                    #70

                                    I think awkward abbreviations like btn are a thing of the past thanks to IntelliSense. I always type out full names. I used to use something like validateButton, but I think buttonValidate would be better, since all buttons would be grouped together, along with the button event handlers that get auto-generated. I wish IntelliSense could group variables apart from functions. I hate scrolling through the mixture of the two. Though, I do believe prefixing could solve the sorting issue. Prefix controls with c_, properties with p_, etc. I don't like it, though.

                                    1 Reply Last reply
                                    0
                                    • R Rocky Moore

                                      Well, since John Simmons got his new TV, he probably will be missing for about two days, but for the rest of you: It has been around two years I think since I have asked this question and I am curious as to if people have changed their minds. Do you use/like the "_" to prefix private members? I personal hate variables prefixed with with _underscores _as _it _can _make _reading _code() _a _pain! In the old days of Assembler and some C code, we lived with it all the time, but I had hoped to never see them again. Now much of the code released by MS has private members prefixed. So, what you think?

                                      Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!

                                      P Offline
                                      P Offline
                                      Purple Fox
                                      wrote on last edited by
                                      #71

                                      not for me thanks! I'll live with _'s in uppercase #defines but that's it. What's wrong with a simple 'm' prefix for member variables and 'mp' for pointer members? Adding a type prefix is overkill and exacerbates R.S.I. Maybe it's a British thing... would be interested to know if we've got a cultural coding standards divide!!

                                      1 Reply Last reply
                                      0
                                      • P Phil Harding

                                        dnh wrote:

                                        We call' em fields

                                        Luddite :)

                                        Phil Harding.
                                        myBlog [^] | mySite [^]

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

                                        Phil HardingLuddite

                                        "Historically, Luddites flourished In Britain from about 1811 to 1816. They were bands of men, organized, masked, anonymous, whose object was to destroy machinery used mostly in the textile industry." :wtf: (Is it O.K. to be a Luddite?[^]) Is that what you think about me? :-D


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

                                        1 Reply Last reply
                                        0
                                        • R realJSOP

                                          I'm not missing. I am working on a series of articles for CP since all the local roads are closed and I can't get to work. :) I only prefix compiler definitions with underscores, like so:

                                          #define _USE_THIS_MSG_ WM_APP+1

                                          I don't prefix variables with underscores, and don't embed variable names with underscores beyond the gratuitous "m_".

                                          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                                          -----
                                          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

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

                                          Wow, I am surprised! I am not sure I would be away from that new TV until my eyes could stand it no longer ;)

                                          Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Ready for Internet TV?

                                          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