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.

    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