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. General Programming
  3. C#
  4. Naming Question

Naming Question

Scheduled Pinned Locked Moved C#
question
35 Posts 16 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.
  • T Tim Groven

    When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.

    OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #5

    Mostly filename But that's because I had to forcibly break myself of using strFilename...

    Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    L 1 Reply Last reply
    0
    • T Tim Groven

      When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.

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

      In this case, path. This is in keeping with Microsoft's convention for naming files.

      Forgive your enemies - it messes with their heads

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      L T 2 Replies Last reply
      0
      • R Ravi Bhavnani

        I prefer filename. However, in public APIs, I name properties FileName and UserName in keeping with Microsoft's convention. /ravi

        My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #7

        Properties would start with a capital-letter, but a variable wouldn't :) Locals are usually Pascal-cased.

        Bastard Programmer from Hell :suss:

        R 1 Reply Last reply
        0
        • P Pete OHanlon

          In this case, path. This is in keeping with Microsoft's convention for naming files.

          Forgive your enemies - it messes with their heads

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #8

          now do you use "filepath" or "filePath"? :confused:

          Luc Pattyn [My Articles] Nil Volentibus Arduum


          Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.

          T 1 Reply Last reply
          0
          • L Lost User

            Properties would start with a capital-letter, but a variable wouldn't :) Locals are usually Pascal-cased.

            Bastard Programmer from Hell :suss:

            R Offline
            R Offline
            Ravi Bhavnani
            wrote on last edited by
            #9

            Yes, I know.  I was referring to the case of the letters within the identifier.  I thought that was blindingly obvious. :) /ravi

            My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

            L 1 Reply Last reply
            0
            • R Ravi Bhavnani

              Yes, I know.  I was referring to the case of the letters within the identifier.  I thought that was blindingly obvious. :) /ravi

              My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #10

              With programmers, nothing is "obvious" unless it's in the specs. I assumed that everyone would simply follow the guidelines from Microsoft, making this a non-question.

              Bastard Programmer from Hell :suss:

              T P 2 Replies Last reply
              0
              • T Tim Groven

                When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.

                B Offline
                B Offline
                BobJanova
                wrote on last edited by
                #11

                'filename' (or 'Filename' if it's a property or 'DoSomethingWithFilename' etc) for me. I think of filename as a single composite word.

                1 Reply Last reply
                0
                • L Luc Pattyn

                  now do you use "filepath" or "filePath"? :confused:

                  Luc Pattyn [My Articles] Nil Volentibus Arduum


                  Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.

                  T Offline
                  T Offline
                  Tim Groven
                  wrote on last edited by
                  #12

                  LOL!

                  1 Reply Last reply
                  0
                  • P Pete OHanlon

                    In this case, path. This is in keeping with Microsoft's convention for naming files.

                    Forgive your enemies - it messes with their heads

                    "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                    My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                    T Offline
                    T Offline
                    Tim Groven
                    wrote on last edited by
                    #13

                    What if it doesn't have a path, just the name of the file itself?

                    L P 2 Replies Last reply
                    0
                    • L Lost User

                      With programmers, nothing is "obvious" unless it's in the specs. I assumed that everyone would simply follow the guidelines from Microsoft, making this a non-question.

                      Bastard Programmer from Hell :suss:

                      T Offline
                      T Offline
                      Tim Groven
                      wrote on last edited by
                      #14

                      Probably a dumb question, but where can I find the Microsoft guidelines for this? :(

                      L R 2 Replies Last reply
                      0
                      • T Tim Groven

                        Probably a dumb question, but where can I find the Microsoft guidelines for this? :(

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #15

                        Caydence wrote:

                        Probably a dumb question

                        It's not, but I'm glad to see that you rather make a "dumb" impression and get an answer than look intelligent and move on without one. Here they are[^] :)

                        Bastard Programmer from Hell :suss:

                        T 1 Reply Last reply
                        0
                        • OriginalGriffO OriginalGriff

                          Mostly filename But that's because I had to forcibly break myself of using strFilename...

                          Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #16

                          Did you used to have lots of lngFilename or blnFilenames as well? ;P

                          Bastard Programmer from Hell :suss:

                          S 1 Reply Last reply
                          0
                          • T Tim Groven

                            What if it doesn't have a path, just the name of the file itself?

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #17

                            fileName and filenameAndPath. Meh.. ..is that with or without extension? A UNC-path, or local?

                            Bastard Programmer from Hell :suss:

                            1 Reply Last reply
                            0
                            • L Lost User

                              Caydence wrote:

                              Probably a dumb question

                              It's not, but I'm glad to see that you rather make a "dumb" impression and get an answer than look intelligent and move on without one. Here they are[^] :)

                              Bastard Programmer from Hell :suss:

                              T Offline
                              T Offline
                              Tim Groven
                              wrote on last edited by
                              #18

                              I don't mind admitting I don't know something. :)

                              K 1 Reply Last reply
                              0
                              • T Tim Groven

                                What if it doesn't have a path, just the name of the file itself?

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

                                Then just filename. It's a standard concatenation and MS is fairly clear on naming for contractions like this; all lower case.

                                Forgive your enemies - it messes with their heads

                                "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                                1 Reply Last reply
                                0
                                • L Lost User

                                  With programmers, nothing is "obvious" unless it's in the specs. I assumed that everyone would simply follow the guidelines from Microsoft, making this a non-question.

                                  Bastard Programmer from Hell :suss:

                                  P Offline
                                  P Offline
                                  PIEBALDconsult
                                  wrote on last edited by
                                  #20

                                  Eddy Vluggen wrote:

                                  the guidelines from Microsoft

                                  So, ummm... explain why Hashtable and DataTable don't agree. :suss:

                                  L S 2 Replies Last reply
                                  0
                                  • T Tim Groven

                                    When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.

                                    P Offline
                                    P Offline
                                    PIEBALDconsult
                                    wrote on last edited by
                                    #21

                                    For a (local) variable or a private field I use the former; otherwise "FileName". Camel case is only for use with Hungarian; and Hungarian is to be avoided. X|

                                    1 Reply Last reply
                                    0
                                    • P PIEBALDconsult

                                      Eddy Vluggen wrote:

                                      the guidelines from Microsoft

                                      So, ummm... explain why Hashtable and DataTable don't agree. :suss:

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #22

                                      I'm not an employee, and I didn't claim it was consistent. It is however, always a good starting place for ideas, and a good place to end discussions.

                                      Bastard Programmer from Hell :suss:

                                      1 Reply Last reply
                                      0
                                      • T Tim Groven

                                        Probably a dumb question, but where can I find the Microsoft guidelines for this? :(

                                        R Offline
                                        R Offline
                                        Ravi Bhavnani
                                        wrote on last edited by
                                        #23

                                        VS' Code Analysis' built-in dictionary checks your identifiers for spelling, grammatical case and other naming conventions of the .NET Framework guidelines.  It's a great a way to gets started, and it's easy to modify/override spellings and naming conventions where necessary. /ravi

                                        My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                                        1 Reply Last reply
                                        0
                                        • T Tim Groven

                                          When naming variables, do you use "filename" or "fileName"? I find myself going back and forth, and can't get my mind to pick one and stick with it.

                                          V Offline
                                          V Offline
                                          V 0
                                          wrote on last edited by
                                          #24

                                          variables: filename Properties, classes, methods... : FileName I hate constructs like sFileName or bMyBool to also indicate the type and also gVariable or _variable to indicate global or class variables, but that might be personal. ;)

                                          V.

                                          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