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.
  • 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
                    • 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.

                      K Offline
                      K Offline
                      Keith Barrow
                      wrote on last edited by
                      #25

                      I personally prefer filename just as other people have stated, it is easy to read. Arguably it is becoming part of the language as a single word, I tend to think of filename as a more specific concept than name of a file that the version with the space implies. As an aside some dictionaries seem to agree .http://dictionary.reference.com/browse/filename[^]. FXCop disagrees and insists on fileName (see this blog post/[^]), and consistency are important. I'd rather agree with the framework and I assume MS uses FXCop's default rules .I can't find an example of fileName, but I'm 75% sure I've seen it somewhere... As a second point filename looks odd set aside filePath. So the answer is for consistancy go for fileName, but filename isn't so bad that you shouldn't use it if you find it easier to read, the important thing is to stick to one version in your code.

                      Sort of a cross between Lawrence of Arabia and Dilbert.[^]
                      -Or-
                      A Dead ringer for Kate Winslett[^]

                      K 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:

                        S Offline
                        S Offline
                        SilimSayo
                        wrote on last edited by
                        #26

                        That's because one is a republican and the other, a democrat.

                        1 Reply Last reply
                        0
                        • L Lost User

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

                          Bastard Programmer from Hell :suss:

                          S Offline
                          S Offline
                          SilimSayo
                          wrote on last edited by
                          #27

                          I saw a variable declared as longAss. Ass was short for assignment no.

                          L 1 Reply Last reply
                          0
                          • S SilimSayo

                            I saw a variable declared as longAss. Ass was short for assignment no.

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

                            That'd be a bigAss in Sql Server types :-D

                            Bastard Programmer from Hell :suss:

                            S 1 Reply Last reply
                            0
                            • L Lost User

                              That'd be a bigAss in Sql Server types :-D

                              Bastard Programmer from Hell :suss:

                              S Offline
                              S Offline
                              SilimSayo
                              wrote on last edited by
                              #29

                              :laugh:

                              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.

                                A Offline
                                A Offline
                                Abhinav S
                                wrote on last edited by
                                #30

                                http://msdn.microsoft.com/en-us/library/xzf533w0%28v=vs.71%29.aspx[^] is a good guideline that you can always follow.

                                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.

                                  A Offline
                                  A Offline
                                  AmitGajjar
                                  wrote on last edited by
                                  #31

                                  Hi, you can use StyleCop for coding convention. there are some rules for naming in it. thanks -Amit.

                                  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.

                                    S Offline
                                    S Offline
                                    Subin Mavunkal
                                    wrote on last edited by
                                    #32

                                    There are so many criterias.If it is a public property , make it "FileName".If it is a private member make it "_fileName" n for local variable make it "fileName".There are naming standards of c#.Go and read it.Or else install SCA for VS and make all naming warnings as errors.It will give u a good idea. :)

                                    1 Reply Last reply
                                    0
                                    • T Tim Groven

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

                                      K Offline
                                      K Offline
                                      Kevin McFarlane
                                      wrote on last edited by
                                      #33

                                      The link Eddy refers to is out of date (though probably still applies). The latest is here. http://msdn.microsoft.com/en-us/library/ms229042.aspx[^]

                                      Kevin

                                      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.

                                        K Offline
                                        K Offline
                                        Kevin McFarlane
                                        wrote on last edited by
                                        #34

                                        I mostly go for filename as it is often interpreted in various places as a single word, e.g., http://en.wikipedia.org/wiki/Filename[^]. Sometimes it depends on what code I'm integrating with. I try to be as consistent as possible in the given context.

                                        Kevin

                                        1 Reply Last reply
                                        0
                                        • K Keith Barrow

                                          I personally prefer filename just as other people have stated, it is easy to read. Arguably it is becoming part of the language as a single word, I tend to think of filename as a more specific concept than name of a file that the version with the space implies. As an aside some dictionaries seem to agree .http://dictionary.reference.com/browse/filename[^]. FXCop disagrees and insists on fileName (see this blog post/[^]), and consistency are important. I'd rather agree with the framework and I assume MS uses FXCop's default rules .I can't find an example of fileName, but I'm 75% sure I've seen it somewhere... As a second point filename looks odd set aside filePath. So the answer is for consistancy go for fileName, but filename isn't so bad that you shouldn't use it if you find it easier to read, the important thing is to stick to one version in your code.

                                          Sort of a cross between Lawrence of Arabia and Dilbert.[^]
                                          -Or-
                                          A Dead ringer for Kate Winslett[^]

                                          K Offline
                                          K Offline
                                          Kevin McFarlane
                                          wrote on last edited by
                                          #35

                                          Keith Barrow wrote:

                                          As a second point filename looks odd set aside filePath

                                          That raises another question. I notice that sometimes an api uses filename to refer just to name of the file, other times to mean the file path. That can be confusing. I tend to adopt a convention of using path for full path and name for just the name. But there is some MS class where in one method they use name to mean just the name and in another method to mean the full path! :omg:

                                          Kevin

                                          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