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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. coding guidelines question

coding guidelines question

Scheduled Pinned Locked Moved C#
question
8 Posts 6 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 Offline
    T Offline
    thepersonof
    wrote on last edited by
    #1

    hey I have a property: int MyProperty{ get{return myProperty;} } When we ran FXCop it threw up: Info : "Do not use names that require case sensitivity for uniqueness. Components must be fully usable from both case-sensitive and case-insensitive languages. Since case-insensitive languages cannot distinguish between two names within the same context that differ only by case, components must avoid this situation." So what should I rename myProperty? cheers

    L D 2 Replies Last reply
    0
    • T thepersonof

      hey I have a property: int MyProperty{ get{return myProperty;} } When we ran FXCop it threw up: Info : "Do not use names that require case sensitivity for uniqueness. Components must be fully usable from both case-sensitive and case-insensitive languages. Since case-insensitive languages cannot distinguish between two names within the same context that differ only by case, components must avoid this situation." So what should I rename myProperty? cheers

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

      Hi, I do this all the time, but only in specific situations; i.e. the local variable is declared private, and the property is either protected or public. And I do not intend on changing that. How else would you come up with two different but related names (don't give me the underscore stuff, such as _myProperty or m_myProperty, I don't like it at all, it lowers the readability of the code). Did you add those different qualifiers when trying? If myProperty and MyProperty both were to have the same access rights (which is private if you dont specify), then I would agree with FxCop. :)

      Luc Pattyn


      try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


      L P 2 Replies Last reply
      0
      • L Luc Pattyn

        Hi, I do this all the time, but only in specific situations; i.e. the local variable is declared private, and the property is either protected or public. And I do not intend on changing that. How else would you come up with two different but related names (don't give me the underscore stuff, such as _myProperty or m_myProperty, I don't like it at all, it lowers the readability of the code). Did you add those different qualifiers when trying? If myProperty and MyProperty both were to have the same access rights (which is private if you dont specify), then I would agree with FxCop. :)

        Luc Pattyn


        try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


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

        I do it the same. Which .NET language is actually case insesitive? regards

        L K 2 Replies Last reply
        0
        • L Lost User

          I do it the same. Which .NET language is actually case insesitive? regards

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

          I dont know, and I would be surprised if any of the major ones would be case-insensitve. I read all languages but on CLR I only speak C# I do know a lot of "cross-linkers" (I am an embedded guy actually) are either case-insensitive or have a switch to let the user choose. :)

          Luc Pattyn


          try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


          1 Reply Last reply
          0
          • L Lost User

            I do it the same. Which .NET language is actually case insesitive? regards

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

            Visual Basic, Eiffel for starters. However, FxCop should really only be objecting about public identifiers that differ only by case. It shouldn't really object to the original example and I would disable that rule.

            Kevin

            1 Reply Last reply
            0
            • T thepersonof

              hey I have a property: int MyProperty{ get{return myProperty;} } When we ran FXCop it threw up: Info : "Do not use names that require case sensitivity for uniqueness. Components must be fully usable from both case-sensitive and case-insensitive languages. Since case-insensitive languages cannot distinguish between two names within the same context that differ only by case, components must avoid this situation." So what should I rename myProperty? cheers

              D Offline
              D Offline
              DavidNohejl
              wrote on last edited by
              #6

              thepersonof wrote:

              So what should I rename myProperty?

              To something meaningful. :)


              [My Blog]
              "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - RĂ¼diger Klaehn
              "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe

              1 Reply Last reply
              0
              • L Luc Pattyn

                Hi, I do this all the time, but only in specific situations; i.e. the local variable is declared private, and the property is either protected or public. And I do not intend on changing that. How else would you come up with two different but related names (don't give me the underscore stuff, such as _myProperty or m_myProperty, I don't like it at all, it lowers the readability of the code). Did you add those different qualifiers when trying? If myProperty and MyProperty both were to have the same access rights (which is private if you dont specify), then I would agree with FxCop. :)

                Luc Pattyn


                try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


                P Offline
                P Offline
                PhilDanger
                wrote on last edited by
                #7

                Luc Pattyn wrote:

                (don't give me the underscore stuff, such as _myProperty or m_myProperty, I don't like it at all, it lowers the readability of the code).

                Just my opinion, but I rather like the m_propertyName way of doing it. With a quick glance in a function you can tell whether or not the code is operating on a member or a local, and also groups them all together in Intellisense so you can easily search through your member variables.

                L 1 Reply Last reply
                0
                • P PhilDanger

                  Luc Pattyn wrote:

                  (don't give me the underscore stuff, such as _myProperty or m_myProperty, I don't like it at all, it lowers the readability of the code).

                  Just my opinion, but I rather like the m_propertyName way of doing it. With a quick glance in a function you can tell whether or not the code is operating on a member or a local, and also groups them all together in Intellisense so you can easily search through your member variables.

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

                  Hi Phil, That is absolutely true, but it does not change the fact I don't like how it looks. Some people still prefix a polish-style type indicator to every variable, as in string strMyName; I prefer identifiers to be strictly functional; I do prefix interface names with "I" since that is a hard convention; and I tend to prefix Controls with their type ("frm", "pan", "btn", ...) mainly to be able to do things such as bool caseSensitive=cbCaseSensitive.Checked; but that is all. I do understand large organizations should impose strict rules, and the larger the project the more it may benefit from them, and from having some prefixes such as the m_ for members. :)

                  Luc Pattyn


                  try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


                  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