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.
  • 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
              • M Michael P Butler

                Rocky Moore wrote:

                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?

                I do in my .NET code. All my class member variables are _ prefixed. Of course most of the time, I access them via Properties rather than directly using the variable. I can't remembered why I moved to _ prefix. It was either because FxCop whined about it or because of some VB issue. In C++, I used m_ so the _prefix is kind of keeping up a long tradition.

                Michael CP Blog [^] Development Blog [^]

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

                Yeah, back in C/C++ I used m_ with along with hungarian notation until 2001 when I moved to .NET and documentation said in the new world we would drop prefixes. For a while I wondered how I would survive without them, but now there is no way to go back :)

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

                1 Reply Last reply
                0
                • S Stuart Dootson

                  I use '_' as a suffix for private member data (which means either all member data of a class or none of it) in C++. However, the rest of the naming is camel-case (capitalized for functions and classes):

                  class SampleClass
                  {
                  public:
                     int SomeMethod() const;
                  private:
                     int aDataMember_;
                  };
                  
                  R Offline
                  R Offline
                  Rocky Moore
                  wrote on last edited by
                  #75

                  Curious, why would you? The only value I have seen anyone mention is for intellisense, so it groups all the local variables together. Is there another reason to not just use a variable name with any extentions?

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

                  S 1 Reply Last reply
                  0
                  • B beatle11

                    Well I like using some prefix. either 'm_' or just the '_'. With C++ for example you can use the 'this' keyword to differentiate but i find it more annoying and confusing to read code this way as I'm sure many programmers do.

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

                    Well, I am in the camp of those that think "this.myDatabase" seems pretty clear ;)

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

                    1 Reply Last reply
                    0
                    • R Rocky Moore

                      Curious, why would you? The only value I have seen anyone mention is for intellisense, so it groups all the local variables together. Is there another reason to not just use a variable name with any extentions?

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

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

                      So that there's a concrete reminder of which names are class members in methods, I guess. Habit as well :-) It works for me, anyway.

                      1 Reply Last reply
                      0
                      • L lotuspro

                        I appear to be in the minority here but I *always* use the underscore to prefix private members. I do this for 2 reasons: 1.) As noted by another commentor, I consider the m_ wholly antiquated and sorely reminiscent of old school VB 2.) whenever I write a new class, especially in something like a data layer, I name my members the same as my field names in my database, but of course I have Properties also and then should also have the same name, so I end up with a simple _fieldName notation. It makes for eacy copy & paste. I'm right, that is all ;)

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

                        lotuspro wrote:

                        I consider the m_ wholly antiquated and sorely reminiscent of old school VB

                        Well, if you started in Assembler or C, you would consdier the "_" wholly antiquated as we put up with those things for years. The "m_" prefix was considered a relief :)

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

                        1 Reply Last reply
                        0
                        • M Member 96

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

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

                          Yeah, think of how many times you instantly typed "m_" ;) I know for me it happened a lot ;)

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

                          1 Reply Last reply
                          0
                          • T the real r2d2

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

                            Beware of programmers who carry screwdrivers - XTalk

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

                            the real r2d2 wrote:

                            aOK = false

                            :) Mine is usually "isOkay" ;)

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

                            1 Reply Last reply
                            0
                            • M MSBassSinger

                              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 Offline
                              J Offline
                              Jasmine2501
                              wrote on last edited by
                              #81

                              MSBassSinger wrote:

                              not likely to change just because Microsoft says so

                              Which is the point I was making initially although I wasn't explicit about it. IF you decide to enact a coding standard, there should be a better reason than 'somebody else is doing it that way', and MS sample code is notorious for being wrong and offensive in many ways - weird naming schemes being only a minor annoyance. I may take an elitist view sometimes, and I agree that code should be easily readable by different people, but one thing I learned managing (baby-sitting) teenagers when I was a retail manager, is that if you coddle them, they will eventually be worthless and you will be doing the job you hired them for. Indicating the data type at every possible invocation of a variable name is like telling someone every day where to find the toilet brush. The problem can be overcome by individuals applying their intelligence, therefore it should be. As in, "I told you it was a private Int32, look... right there, in the code that is right in front of your face..." In weakly-typed languages like javascript, I'll make an exception - the prefixes are helpful (although they still mean nothing). I've been lookin at code for 20 years, and variable prefixes have always annoyed me, even when we didn't have intellisense. Occasionally, you see things like this: private string strValue; private int intValue; You see this all the time in sample code... without the prefix, you have two variables with the same name. In sample code this is fine, especially if you are comparing the behavior of different types. In the sample case, the meaning of the variable is not important, so the generic term "value" applies, and the important issue becomes the type itself. When you have a situation like that, indicating the type is helpful, but I wouldn't do it with every variable name always and forever, only when needed. This is the only situation I can think of for that, where two variables actually represent the same thing, but using different data types... you see this in graphics sometimes: float viewX, viewY, viewZ; // (-1.0 < x|y < 1.0), (Z = +/- any depth) int screenX, screenY, screenZ; // (0 < x < 1024), (0 < y < 768), (z > 0) (again though, I don't indicate the type, only the important difference, one is in the viewport and one is in the screen, then I indicate the acceptable ranges in a comment, and I never have to say anything else about these variables ever again) I wouldn't

                              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!

                                D Offline
                                D Offline
                                db_cooper1950
                                wrote on last edited by
                                #82

                                I write code in both VB.NET and C#, and I used to be mainly a VB 6 programmer. Personally if I am declaring a private member / variable I like to prefix it with just the "m" as in mPrivate. I hate using and/or reading the the underscore when m is not only easier on the eyes, it is easier to type, and therefore takes less overall time to write the code. :)

                                DB_Cooper1950 "Life is like a box of..."

                                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
                                  Tim Yen
                                  wrote on last edited by
                                  #83

                                  No i dont like em! Tim

                                  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
                                    jiuli
                                    wrote on last edited by
                                    #84

                                    Maybe it's an annoying thing to review the codes which are full of the underscores. But it derived from the C and assembly languages, unfortunatelly, our senior leader came from this era, just to ingratiate ourself with the manager. So we must write the codes like this. :-D:-D:-D:-D

                                    R 1 Reply Last reply
                                    0
                                    • J jiuli

                                      Maybe it's an annoying thing to review the codes which are full of the underscores. But it derived from the C and assembly languages, unfortunatelly, our senior leader came from this era, just to ingratiate ourself with the manager. So we must write the codes like this. :-D:-D:-D:-D

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

                                      Well, I am from that same era and had enough of them more than a decade ago :) It is important though to code by the standards of a company where you work or in the lack of a standard being implemented, by the standards used in the large majority of work (which sometimes is not excatly fun ;) )

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

                                      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?

                                        M Offline
                                        M Offline
                                        meeyak
                                        wrote on last edited by
                                        #86

                                        I like _em! I find it convenient to have all of the private members listed together in the intellisense.

                                        carpe diem

                                        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
                                          EmergentComprehension
                                          wrote on last edited by
                                          #87

                                          One take on this question could be "m_" vs "_". Either is good as they distinguish the scope/lifetime at a glance. Some people express a loathing for "m_", as its old hat. C++ & vb6 typically used some m_ or mvar or similar prefix. I was happy with that. Why change it? The point that many raised is either prefix is fine, so long as its consistent? So why oh why did it have to change?

                                          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