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. Name Conventions

Name Conventions

Scheduled Pinned Locked Moved The Lounge
question
48 Posts 31 Posters 6 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 alex barylski

    I typically use an prefixed underscore to indicate private/protected members :) Not that anyone would care :P

    I finally got a job doing something I enjoy and I"m good at...15 hour days seem like play time :P

    G Offline
    G Offline
    Gary Wheeler
    wrote on last edited by
    #22

    OMG. There's another one us out there that uses this convention. I'm not alone anymore. (sniff)


    Software Zen: delete this;

    P 1 Reply Last reply
    0
    • C Christian Graus

      I thought we were talking about methods.   For variables and properties, I do the same.  upper/lower case differences are not enough to be CLS compiant, because VB sucks.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      S Offline
      S Offline
      subai
      wrote on last edited by
      #23

      i used to (and i like to) use prefix underscore in private members but it's not recommended by the boss(it's forbidden) :(

      I Wish the Life Had CTRL-Z

      1 Reply Last reply
      0
      • G Gary Wheeler

        OMG. There's another one us out there that uses this convention. I'm not alone anymore. (sniff)


        Software Zen: delete this;

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #24

        I do, but only for private members. As has been written elsewhere, underscores on protected members will raise errors because they are not CLS Compliant.

        the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
        Deja View - the feeling that you've seen this post before.

        G 1 Reply Last reply
        0
        • P Pete OHanlon

          I do, but only for private members. As has been written elsewhere, underscores on protected members will raise errors because they are not CLS Compliant.

          the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
          Deja View - the feeling that you've seen this post before.

          G Offline
          G Offline
          Gary Wheeler
          wrote on last edited by
          #25

          Our naming conventions are something like this: PascalCase for public classes, members, 'file' static values, and globals. _PascalCaseWithLeadingUnderscore for private/protected classes and members. camelCase or lower_case_with_underscores for local variables. ALL_UPPER_CASE_FOR_DEFINES which are required to be manifest constants only. If we ever start doing .NET development (we're currently a C++/MFC house), we may need to modify our conventions. .NET enforcing a naming convention is annoyingly reminiscent of the Ada development tools I had to deal with back in the late 80's. They were equally obnoxious about requiring adherence to some academic's notion of proper programming technique. I am of the "Grady Booch must die" programming school, myself :|.


          Software Zen: delete this;

          1 Reply Last reply
          0
          • T Tim Craig

            Ennis Ray Lynch, Jr. wrote:

            I don't know why the folks at MS tried to dictate a different style.

            Because Not Invented Here is alive and rampant at Microsoft. They just, a priori, know what's right.

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

            G Offline
            G Offline
            Gary Wheeler
            wrote on last edited by
            #26

            Tim Craig wrote:

            They just, a priori, know what's right

            How does an 800 pound gorilla write software? (wait for it) However he likes.


            Software Zen: delete this;

            1 Reply Last reply
            0
            • P Paul Selormey

              Christian Graus wrote:

              CLS compiant, because VB sucks.

              Wrong, it is because CLS==language independence, a feature it boasts off over Java bytecode. BTW, it is your perfect C# compiler that will complain. If you write and consume your components only in C#, just remove the CLS compliant attribute, and stop blaming VB for your bugs ;P With love, Paul.

              Jesus Christ is LOVE! Please tell somebody.

              N Offline
              N Offline
              Nemanja Trifunovic
              wrote on last edited by
              #27

              Paul Selormey wrote:

              Wrong, it is because CLS==language independence, a feature it boasts off over Java bytecode.

              Off topic: Java bytecode is language independent as well, and there are some very nice languages that target JVM, such as Scala[^], Nice[^] and Groovy[^]. Note that I don't count Java as a nice language for JVM ;)


              Programming Blog utf8-cpp

              1 Reply Last reply
              0
              • C Colin Angus Mackay

                Use getValue() in Java and GetValue() in .NET


                Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

                R Offline
                R Offline
                RichardGrimmer
                wrote on last edited by
                #28

                Colin Angus Mackay wrote:

                GetValue() in .NET

                I'd disagree - for a start I always use getValue, and second off, all the M$ events I've been to recently have had their people using it too... But at the end of the day, I'd say it's COMPLETELY personal preference :)

                "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

                G 1 Reply Last reply
                0
                • R RichardGrimmer

                  Colin Angus Mackay wrote:

                  GetValue() in .NET

                  I'd disagree - for a start I always use getValue, and second off, all the M$ events I've been to recently have had their people using it too... But at the end of the day, I'd say it's COMPLETELY personal preference :)

                  "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

                  G Offline
                  G Offline
                  Grimolfr
                  wrote on last edited by
                  #29

                  RichardGrimmer wrote:

                  I'd say it's COMPLETELY personal preference

                  Actually, I'd say it's the preference of whoever will own the code you're writing. If you only code for yourself, then you are correct, if you're coding for others, you should follow their standards, practices, and guidelines. And in my experience, most places that actually understand the concepts of standards and practices tend to follow the guidelines that Christian has already stated. Making them good habits to get into.


                  Grim

                  (aka Toby)

                  MCDBA, MCSD, MCP+SB

                  Need a Second Life?[^]

                  SELECT * FROM users WHERE clue IS NOT NULL GO

                  (0 row(s) affected)

                  1 Reply Last reply
                  0
                  • C Colin Angus Mackay

                    Use getValue() in Java and GetValue() in .NET


                    Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

                    N Offline
                    N Offline
                    Nordin Rahman
                    wrote on last edited by
                    #30

                    I prefer GetValue() in .NET too. However, if I am trying to port getter/setter methods written in Java to .NET, it is better for me to write them in property syntax. eg (C#): private int value; /// /// Get and set the value /// public int Value { get { return value; } set { if (this.value != value) this.value = value); } } You can refer MS website regarding. http://msdn2.microsoft.com/en-us/ms229002(VS.80).aspx[^] :)

                    I like you, and I love programming more.

                    1 Reply Last reply
                    0
                    • M Monin D

                      Hello, When i should to name method with uppercase letter and when not? When I should use getValue() and when GetValue()? Thanks.

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

                      The problem is more with the name than that case. As long as you consistently use the same casing you won't have a problem. You should pick a better name than GetValue, though. Pick a name that indicates what you are getting - all of your accessor functions are going to "get a value" of some kind. I had a guy a while back who thought it was funny to give his stuff names like "process_something" and "my_string"... this bites you in the ass pretty quick.

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

                      1 Reply Last reply
                      0
                      • M Monin D

                        Hello, When i should to name method with uppercase letter and when not? When I should use getValue() and when GetValue()? Thanks.

                        I Offline
                        I Offline
                        Igor Velikorossov
                        wrote on last edited by
                        #32

                        I reckon if you use .NET you should stick with The Guidelines - Design Guidelines, Managed code and the .NET Framework[^]

                        M 1 Reply Last reply
                        0
                        • A Aryo Handono

                          How about in VB ? ;P

                          "Courage choose who will follow, Fate choose who will lead" - Lord Gunner, Septerra Core "Press any key to continue, where's the ANY key ?" - Homer Simpsons Drinking gives me amazing powers of insight. I can solve all the worlds problems when drunk, but can never remember the solutions in the morning. - Michael P Butler to Paul Watson on 12/08/03

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

                          Wouldn't that be: GETVALUE() ;)

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

                          P 1 Reply Last reply
                          0
                          • D DavidNohejl

                            Steve Hansen wrote:

                            However, an underscore in any other position in an element name is CLS-compliant.

                            I understood this as _element is invalid, but element_, my_element etc are OK.

                            Steve Hansen wrote:

                            So it only matters for public properties/methods which I don't think they do.

                            Agreed.


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

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

                            dnh wrote:

                            I understood this as _element is invalid, but element_, my_element etc are OK.

                            All ugly and should be banned! ;)

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

                            1 Reply Last reply
                            0
                            • C Colin Angus Mackay

                              Use getValue() in Java and GetValue() in .NET


                              Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

                              N Offline
                              N Offline
                              NileshBhatkhalkar
                              wrote on last edited by
                              #35

                              Follow a consistent approach regardless of any language. The standardization of naming conventions should be organization-wide and not restricted to any language. Following are the advantages of adhering to common standards: • Programmers can go into any code and figure out the code easily and fast. • New people can get up to speed quickly. • People make fewer mistakes in consistent environments. • Increase the readability and maintainability of the code and hence the productivity of the team. So I would suggest you standardize the coding standards. :rolleyes: I hope this was helpful to you.... Thanks, Nilesh Bhatkhalkar

                              Cheers, Nilesh Prakash Bhatkhalkar

                              C J 2 Replies Last reply
                              0
                              • N NileshBhatkhalkar

                                Follow a consistent approach regardless of any language. The standardization of naming conventions should be organization-wide and not restricted to any language. Following are the advantages of adhering to common standards: • Programmers can go into any code and figure out the code easily and fast. • New people can get up to speed quickly. • People make fewer mistakes in consistent environments. • Increase the readability and maintainability of the code and hence the productivity of the team. So I would suggest you standardize the coding standards. :rolleyes: I hope this was helpful to you.... Thanks, Nilesh Bhatkhalkar

                                Cheers, Nilesh Prakash Bhatkhalkar

                                C Offline
                                C Offline
                                Colin Angus Mackay
                                wrote on last edited by
                                #36

                                NileshBhatkhalkar wrote:

                                The standardization of naming conventions should be organization-wide and not restricted to any language.

                                That's nice in theory, but if you look at the standard for Java and the standard for .NET you'll see they are different. If you implement an organisation wide standard that ignores the language you'll end up with two standards in one piece of code. One standard defined by your organisation and one standard defined by the language vendor. I've worked in a company that did that and quite frankly the code was a mess. When I moved to a new language I didn't immediately know where the framework stopped and the company's code started and I got myself in to a right mess when trying to figure out how to call stuff.

                                NileshBhatkhalkar wrote:

                                I hope this was helpful to you....

                                Sorry, but experience has taught me that this is not the way to go. Be as consistent as possible by all means, but yield to the existing standards defined by the language vendor if need be.


                                Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

                                1 Reply Last reply
                                0
                                • C Christian Graus

                                  Paul Selormey wrote:

                                  Wrong, it is because CLS==language independence, a feature it boasts off over Java bytecode.

                                  True -and to make it language independant, they needed to make it case insensitive.  Which languages are case insensitive ?

                                  Paul Selormey wrote:

                                  BTW, it is your perfect C# compiler that will complain.

                                  Of course it will.  The VB.NET compiler is too stupid to see a difference between var, Var and VAR to start with.

                                  Paul Selormey wrote:

                                  just remove the CLS compliant attribute,

                                  I've been known to do that, actually

                                  Paul Selormey wrote:

                                  and stop blaming VB for your bugs

                                  ROTFL - you're obviously kidding around, but either way, I think a language being case insensitive is just plain dumb.  It's obviously a 'feature' added to VB.NET to make it easier, it's not something that has a real advantage beyond that.

                                  Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                                  P Offline
                                  P Offline
                                  Paul Selormey
                                  wrote on last edited by
                                  #37

                                  Christian Graus wrote:

                                  Which languages are case insensitive ?

                                  Maybe for the .NET languages you have access to VB.NET. I know of at least Fortran and there is a .NET version.

                                  Christian Graus wrote:

                                  Of course it will. The VB.NET compiler is too stupid to see a difference between var, Var and VAR to start with.

                                  Of what value is the claim that var, Var and VAR are different? Windows is not case sensitive does not make it dump because UNIX/Linux is.

                                  Christian Graus wrote:

                                  ROTFL - you're obviously kidding around, but either way, I think a language being case insensitive is just plain dumb.

                                  Fortran, SQL are case insensitive and I have never found them dump. They do just what they are designed to do and they do it perfectly. I used Fortran for both my MSc and PhD simulations work and never wished I used anything different.

                                  Christian Graus wrote:

                                  It's obviously a 'feature' added to VB.NET to make it easier, it's not something that has a real advantage beyond that.

                                  Neither do I found the case sensitivity of C#/C/C++ to be off any special advantage. I will definitely not have method/function names like getValue and GetValue to mean different things in my code. If you will, simply accept that as a personal preference and has nothing to do with programming skill or whatever. The history of C, the mother of C#, tells you why they needed a case sensitivity. With love, Paul.

                                  Jesus Christ is LOVE! Please tell somebody.

                                  C A 2 Replies Last reply
                                  0
                                  • I Igor Velikorossov

                                    I reckon if you use .NET you should stick with The Guidelines - Design Guidelines, Managed code and the .NET Framework[^]

                                    M Offline
                                    M Offline
                                    Monin D
                                    wrote on last edited by
                                    #38

                                    good link, thanks

                                    1 Reply Last reply
                                    0
                                    • P Paul Selormey

                                      Christian Graus wrote:

                                      Which languages are case insensitive ?

                                      Maybe for the .NET languages you have access to VB.NET. I know of at least Fortran and there is a .NET version.

                                      Christian Graus wrote:

                                      Of course it will. The VB.NET compiler is too stupid to see a difference between var, Var and VAR to start with.

                                      Of what value is the claim that var, Var and VAR are different? Windows is not case sensitive does not make it dump because UNIX/Linux is.

                                      Christian Graus wrote:

                                      ROTFL - you're obviously kidding around, but either way, I think a language being case insensitive is just plain dumb.

                                      Fortran, SQL are case insensitive and I have never found them dump. They do just what they are designed to do and they do it perfectly. I used Fortran for both my MSc and PhD simulations work and never wished I used anything different.

                                      Christian Graus wrote:

                                      It's obviously a 'feature' added to VB.NET to make it easier, it's not something that has a real advantage beyond that.

                                      Neither do I found the case sensitivity of C#/C/C++ to be off any special advantage. I will definitely not have method/function names like getValue and GetValue to mean different things in my code. If you will, simply accept that as a personal preference and has nothing to do with programming skill or whatever. The history of C, the mother of C#, tells you why they needed a case sensitivity. With love, Paul.

                                      Jesus Christ is LOVE! Please tell somebody.

                                      C Offline
                                      C Offline
                                      Christian Graus
                                      wrote on last edited by
                                      #39

                                      Paul Selormey wrote:

                                      I know of at least Fortran and there is a .NET version.

                                      OK, I didn't know that.  I wonder mow many computers used upper and lower case when FORTRAN was developed ?

                                      Paul Selormey wrote:

                                      The history of C, the mother of C#

                                      You're totally wrong.  C has nothing to do with C#, and C++ has next to nothing to do with C#.  They are totally unrelated.

                                      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

                                      P 1 Reply Last reply
                                      0
                                      • N NileshBhatkhalkar

                                        Follow a consistent approach regardless of any language. The standardization of naming conventions should be organization-wide and not restricted to any language. Following are the advantages of adhering to common standards: • Programmers can go into any code and figure out the code easily and fast. • New people can get up to speed quickly. • People make fewer mistakes in consistent environments. • Increase the readability and maintainability of the code and hence the productivity of the team. So I would suggest you standardize the coding standards. :rolleyes: I hope this was helpful to you.... Thanks, Nilesh Bhatkhalkar

                                        Cheers, Nilesh Prakash Bhatkhalkar

                                        J Offline
                                        J Offline
                                        jcmaida
                                        wrote on last edited by
                                        #40

                                        Nilesh, Your comments about naming conventions are exactly correct. Good words.:) Maida

                                        1 Reply Last reply
                                        0
                                        • P Paul Selormey

                                          Christian Graus wrote:

                                          Which languages are case insensitive ?

                                          Maybe for the .NET languages you have access to VB.NET. I know of at least Fortran and there is a .NET version.

                                          Christian Graus wrote:

                                          Of course it will. The VB.NET compiler is too stupid to see a difference between var, Var and VAR to start with.

                                          Of what value is the claim that var, Var and VAR are different? Windows is not case sensitive does not make it dump because UNIX/Linux is.

                                          Christian Graus wrote:

                                          ROTFL - you're obviously kidding around, but either way, I think a language being case insensitive is just plain dumb.

                                          Fortran, SQL are case insensitive and I have never found them dump. They do just what they are designed to do and they do it perfectly. I used Fortran for both my MSc and PhD simulations work and never wished I used anything different.

                                          Christian Graus wrote:

                                          It's obviously a 'feature' added to VB.NET to make it easier, it's not something that has a real advantage beyond that.

                                          Neither do I found the case sensitivity of C#/C/C++ to be off any special advantage. I will definitely not have method/function names like getValue and GetValue to mean different things in my code. If you will, simply accept that as a personal preference and has nothing to do with programming skill or whatever. The history of C, the mother of C#, tells you why they needed a case sensitivity. With love, Paul.

                                          Jesus Christ is LOVE! Please tell somebody.

                                          A Offline
                                          A Offline
                                          A J E E S H
                                          wrote on last edited by
                                          #41

                                          Paul Selormey wrote:

                                          The history of C, the mother of C#, tells you why they needed a case sensitivity.

                                          Can you please say why?:)

                                          Regards, --=A J E E S H=--

                                          P 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