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. Naming conventions in .NET?

Naming conventions in .NET?

Scheduled Pinned Locked Moved The Lounge
csharpjavadelphihtmldotnet
27 Posts 17 Posters 4 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.
  • D Dominik Reichl

    I'm wondering what the real rules are behind the class naming in the .NET framework (are there?)... On the Naming Guidelines[^] page they say: When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io. Ok, that's fine. I see classes like AsnEncodedData, OidCollection, CspProviderFlags, ... On the other hand we find classes like ASCIIEncoding, UTF7Encoding, UTF8Encoding, UTF32Encoding, RNGCryptoServiceProvider, DESCryptoServiceProvider, DSACryptoServiceProvider, HMAC* (7 classes), MACTripleDES, CryptoAPITransform, ... Am I missing a naming rule here or are those just named inconsistently? Of course we're far away from the Java naming hell, but anyway the .NET framework doesn't seem to be perfect :~


    _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

    M Offline
    M Offline
    Michael Dunn
    wrote on last edited by
    #17

    Brad Abrams has written much about this topic on his blog. The guidelines were put in place after a lot of code had already been written and shipped, and by that time it was too late to rename classes to fit the rules. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

    1 Reply Last reply
    0
    • M Mircea Grelus

      Camel case is the practice of writing compound words or phrases where the words are joined without spaces, and each word is capitalized within the compound Camel case[^] Since ASCII, UTF are not names by themselves, they are acronyms the ASCIIEncoding, UTF7Encoding casing is correct. I guess you dont have a problem with IO so them why would ASCII be any different? regards, Mircea Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #18

      Because the MS recommendation is to only write acronyms that are fewer than 3 letters in uppercase. So IO is uppercase, but ASCII should be Ascii, but is not. Regards Senthil _____________________________ My Blog | My Articles | My Flickr | WinMacro

      1 Reply Last reply
      0
      • D Dominik Reichl

        I'm wondering what the real rules are behind the class naming in the .NET framework (are there?)... On the Naming Guidelines[^] page they say: When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io. Ok, that's fine. I see classes like AsnEncodedData, OidCollection, CspProviderFlags, ... On the other hand we find classes like ASCIIEncoding, UTF7Encoding, UTF8Encoding, UTF32Encoding, RNGCryptoServiceProvider, DESCryptoServiceProvider, DSACryptoServiceProvider, HMAC* (7 classes), MACTripleDES, CryptoAPITransform, ... Am I missing a naming rule here or are those just named inconsistently? Of course we're far away from the Java naming hell, but anyway the .NET framework doesn't seem to be perfect :~


        _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

        J Offline
        J Offline
        Jorgen Sigvardsson
        wrote on last edited by
        #19

        It's just plain silly to use pascal camel case for acronyms.

        1 Reply Last reply
        0
        • D Dominik Reichl

          I'm wondering what the real rules are behind the class naming in the .NET framework (are there?)... On the Naming Guidelines[^] page they say: When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io. Ok, that's fine. I see classes like AsnEncodedData, OidCollection, CspProviderFlags, ... On the other hand we find classes like ASCIIEncoding, UTF7Encoding, UTF8Encoding, UTF32Encoding, RNGCryptoServiceProvider, DESCryptoServiceProvider, DSACryptoServiceProvider, HMAC* (7 classes), MACTripleDES, CryptoAPITransform, ... Am I missing a naming rule here or are those just named inconsistently? Of course we're far away from the Java naming hell, but anyway the .NET framework doesn't seem to be perfect :~


          _outp(0x64, 0xAD); and __asm mov al, 0xAD __asm out 0x64, al do the same... but what do they do?? ;) (doesn't work on NT)

          R Offline
          R Offline
          Robert Ranck
          wrote on last edited by
          #20

          The official .NET Framework guidelines are documented in the book "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries". This book includes the guideline to use Pascal case or camel case for acronyms more than two characters, but before getting to that it says, "In general, it is important to avoid using acronyms in identifier names unless they are in common usage and are immediately understandable to anyone who might use the framework." (Section 3.2.1. Capitalizing Acronyms). In an annotation in that same section, co-author Brad Abrams acknowledges that the Framework does not consistently follow these guidelines, and states, "For the most part, our customers have seen the places in which we have diverged from these guidelines (for even the best excuse) as warts in the Framework."

          R 1 Reply Last reply
          0
          • R Robert Ranck

            The official .NET Framework guidelines are documented in the book "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries". This book includes the guideline to use Pascal case or camel case for acronyms more than two characters, but before getting to that it says, "In general, it is important to avoid using acronyms in identifier names unless they are in common usage and are immediately understandable to anyone who might use the framework." (Section 3.2.1. Capitalizing Acronyms). In an annotation in that same section, co-author Brad Abrams acknowledges that the Framework does not consistently follow these guidelines, and states, "For the most part, our customers have seen the places in which we have diverged from these guidelines (for even the best excuse) as warts in the Framework."

            R Offline
            R Offline
            Robert Ranck
            wrote on last edited by
            #21

            I should have given full credit to the authors and publisher when quoting that book. "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" by Krzysztof Cwalina and Brad Abrams published by Addison-Wesley as part of the Microsoft .NET Development Series

            1 Reply Last reply
            0
            • N Nish Nishant

              ASCII, UTF, API etc are acronyms. You don't want a class called AmericanStandardCodeForInformationInterchangeEncoding do you? Regards, Nish


              Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
              The Ultimate Grid - The #1 MFC grid out there!

              G Offline
              G Offline
              geek0735
              wrote on last edited by
              #22

              I hate to be a stickler, but since we're picking at nits: word-objects like "UTF", "RNG", "DSA", etc are not acronyms, they are initialisms. An acronym is technically an initialism where the initials constitute a pronounceable word, like "GUI" or "ASCII". Not that anybody cares... Courtesy of the Ben Hunter school of useless knowledge...

              M 1 Reply Last reply
              0
              • M Mircea Grelus

                Camel case = grouping of word with first letter capitalized. ASCI (American Standard Code for Information Interchange), UTF7 (7-bit Unicode Transformation Format). ASCII and UTF are not names by themselves. I find naming ASCIIEncoding or UTF7Encoding proper. It would be improper to name them asciiEncoding or utf7Encoding. regards, Mircea Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.

                D Offline
                D Offline
                dr TyGER Konstantin
                wrote on last edited by
                #23

                Completly agree! There is rules, but there is also exception to the rule! UTF7*, ACSI* - is right, becouse it's exceptions...

                1 Reply Last reply
                0
                • M Mircea Grelus

                  Camel case = grouping of word with first letter capitalized. ASCI (American Standard Code for Information Interchange), UTF7 (7-bit Unicode Transformation Format). ASCII and UTF are not names by themselves. I find naming ASCIIEncoding or UTF7Encoding proper. It would be improper to name them asciiEncoding or utf7Encoding. regards, Mircea Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.

                  S Offline
                  S Offline
                  Steven J Jowett
                  wrote on last edited by
                  #24

                  Interesting debate, but unless you plan to distribute your components, classes etc to third-parties, does it really matter? Having said that, I believe that most of us are intelligent enough to work out that ASCIIEncoding and AsciiEncoding are the same thing. Steve Jowett. Wait for my first born to arrive, any day now :-D

                  M 1 Reply Last reply
                  0
                  • S Steven J Jowett

                    Interesting debate, but unless you plan to distribute your components, classes etc to third-parties, does it really matter? Having said that, I believe that most of us are intelligent enough to work out that ASCIIEncoding and AsciiEncoding are the same thing. Steve Jowett. Wait for my first born to arrive, any day now :-D

                    M Offline
                    M Offline
                    Mircea Grelus
                    wrote on last edited by
                    #25

                    Of course that the naming convension wouldn't get in the way of doing our job. But it can cause impediments if one project is split among more development groups. When all the parts must be combined it is really a pain in the a** to start renaming classes and namespaces. It could introduce bugs into the project and also it's just stupid wasted time. Of course this doesn't happen that often if the project management is good, but it was just an example. regards, Mircea Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.

                    S 1 Reply Last reply
                    0
                    • M Mircea Grelus

                      Of course that the naming convension wouldn't get in the way of doing our job. But it can cause impediments if one project is split among more development groups. When all the parts must be combined it is really a pain in the a** to start renaming classes and namespaces. It could introduce bugs into the project and also it's just stupid wasted time. Of course this doesn't happen that often if the project management is good, but it was just an example. regards, Mircea Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.

                      S Offline
                      S Offline
                      Steven J Jowett
                      wrote on last edited by
                      #26

                      I take your point. But what I was trying to say (badly) is if you are coding only for your in house development then you to free to dictate any coding standard you choose. When developing within a group, the coding standards should be agreed by all concerned and implemented accordingly. Having said that, you should also keep in mind that your company my employ other developers after you leave, who may pick up your work. I they do not understand your coding methods and standards then the chances are they'll bin your work and do it again. Most importantly, your code should be easy to follow, and the best test for that is give it to a non-developer and ask them what each section does. Ideally they should be able to tell from the procedure name. Steve Jowett

                      1 Reply Last reply
                      0
                      • G geek0735

                        I hate to be a stickler, but since we're picking at nits: word-objects like "UTF", "RNG", "DSA", etc are not acronyms, they are initialisms. An acronym is technically an initialism where the initials constitute a pronounceable word, like "GUI" or "ASCII". Not that anybody cares... Courtesy of the Ben Hunter school of useless knowledge...

                        M Offline
                        M Offline
                        machman1
                        wrote on last edited by
                        #27

                        That wasn't useless my friend! :-D

                        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