Generic Class Naming Convention

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sloan

    #1

    Generic Class Naming Convention


    I've noticed alot of people tacking on a "T" for a generic abled version of
    an older class.

    Ex:

    1.1 Code

    IDataStore


    I take it, and while I keep IDataStore around for 2.0 version, I decide to
    make a Generic version.

    So I see this:

    IDataStoreT < T >


    Is that something that just developed? Or does it (the naming convention)
    come from somewhere?


    I've got Brad Abrams book here (Framework Design Guidelines) and it doesn't
    speak to the classname specifically, only the parameter type <T>.


    Thanks.


  • Mythran

    #2
    Re: Generic Class Naming Convention



    "Bob Powell [MVP]" <bob@spamkiller bobpowell.netwr ote in message
    news:15D9268C-8CED-4AEA-B03E-A7037DB31E35@mi crosoft.com...
    >I would keep away from such naming. It's not necessary because the template
    >syntax and signatures are totlly different to those of the straight classes
    >and such indicative naming schemes are frowned upon, probably because the
    >schemes change so often that code that uses them can become either
    >unreadable or confusuing when modifications to the convention orrur.
    >
    --
    --
    Bob Powell [MVP]
    Visual C#, System.Drawing
    >

    I'm still using .Net 2003 :)

    Say you have your own class named "Collection ". Can you create a new type
    under the same namespace with the same name for a generic, "Collection<T>" ?
    If not (and Collection was an actual named class that described both
    completely with the exception of one is generic), what would you name the
    "New" generic "Collection<T>" ?

    Thanks,
    Mythran


    Comment

    • Mythran

      #3
      Re: Generic Class Naming Convention



      "Mythran" <kip_potter@hot mail.comwrote in message
      news:436410F1-FAA1-404E-8331-62DEC4358B5A@mi crosoft.com...
      >
      >
      "Bob Powell [MVP]" <bob@spamkiller bobpowell.netwr ote in message
      news:15D9268C-8CED-4AEA-B03E-A7037DB31E35@mi crosoft.com...
      >>I would keep away from such naming. It's not necessary because the
      >>template syntax and signatures are totlly different to those of the
      >>straight classes and such indicative naming schemes are frowned upon,
      >>probably because the schemes change so often that code that uses them can
      >>become either unreadable or confusuing when modifications to the
      >>convention orrur.
      >>
      >--
      >--
      >Bob Powell [MVP]
      >Visual C#, System.Drawing
      >>
      >
      >
      I'm still using .Net 2003 :)
      >
      Say you have your own class named "Collection ". Can you create a new type
      under the same namespace with the same name for a generic,
      "Collection<T>" ? If not (and Collection was an actual named class that
      described both completely with the exception of one is generic), what
      would you name the "New" generic "Collection<T>" ?
      >
      Thanks,
      Mythran
      >
      >
      Nevermind, I think. I believe Jon answered my question in his reply about 2
      minutes after my message lol.

      Mythran


      Comment

      • GlennDoten

        #4
        Re: Generic Class Naming Convention

        Mythran wrote:
        Say you have your own class named "Collection ". Can you create a new
        type under the same namespace with the same name for a generic,
        "Collection<T>" ? If not (and Collection was an actual named class that
        described both completely with the exception of one is generic), what
        would you name the "New" generic "Collection<T>" ?
        Yes, this works fine:

        namespace Foo
        {
        public class Collection { }
        public class Collection<T{ }
        public class Collection<T1,T 2{ }
        }

        So there's no need to name the generic ones CollectionT<T>. (And what
        would you name the second generic one above anyhow? CollectionTT?)

        --
        -glenn-

        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: Generic Class Naming Convention

          Mythran <kip_potter@hot mail.comwrote:
          Say you have your own class named "Collection ". Can you create a new type
          under the same namespace with the same name for a generic, "Collection<T>" ?
          Yes, you can. Indeed, the System namespace in .NET 2.0 has the
          Nullable<Tstruc t and the Nullable class.

          --
          Jon Skeet - <skeet@pobox.co m>
          http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
          If replying to the group, please do not mail me too

          Comment

          • Jon Skeet [C# MVP]

            #6
            Re: Generic Class Naming Convention

            Mythran <kip_potter@hot mail.comwrote:
            Nevermind, I think. I believe Jon answered my question in his reply about 2
            minutes after my message lol.
            But hey, that hasn't stopped me from answering it again ;)

            (Note to self: read all messages before starting to reply...)

            --
            Jon Skeet - <skeet@pobox.co m>
            http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
            If replying to the group, please do not mail me too

            Comment

            Working...