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. Other Discussions
  3. The Weird and The Wonderful
  4. Great C# generics naming [modified]

Great C# generics naming [modified]

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpcode-reviewcareer
8 Posts 4 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.
  • M Offline
    M Offline
    makumazan84
    wrote on last edited by
    #1

    I've got a co-worker, who has done some great job in producing handsome and easy to understand pieces of code. The previos pearl was a 238 lines method, and when I asked to refactor it, he told that it was just fine. Still, this one is my favorite. (The name of the metHod is not that important)

    public void SendMetod(IEnumerable t)
    where T: class
    where T1: class
    where T2: class

    For some company issues I cannot post the method itself(a nice piece of work too, trust me), but it's header is adorable. T, T1, T2 and t is kinna brain explosive -- Modified Thursday, September 2, 2010 5:53 AM

    A B 2 Replies Last reply
    0
    • M makumazan84

      I've got a co-worker, who has done some great job in producing handsome and easy to understand pieces of code. The previos pearl was a 238 lines method, and when I asked to refactor it, he told that it was just fine. Still, this one is my favorite. (The name of the metHod is not that important)

      public void SendMetod(IEnumerable t)
      where T: class
      where T1: class
      where T2: class

      For some company issues I cannot post the method itself(a nice piece of work too, trust me), but it's header is adorable. T, T1, T2 and t is kinna brain explosive -- Modified Thursday, September 2, 2010 5:53 AM

      A Offline
      A Offline
      AspDotNetDev
      wrote on last edited by
      #2

      T2 was one of those rare movies where the sequel was better than the original. I understand what T1 and T2 are, but what is T? A prequel, perhaps? In any event, I'm glad they're making it with class. :)

      [Forum Guidelines]

      M K 2 Replies Last reply
      0
      • A AspDotNetDev

        T2 was one of those rare movies where the sequel was better than the original. I understand what T1 and T2 are, but what is T? A prequel, perhaps? In any event, I'm glad they're making it with class. :)

        [Forum Guidelines]

        M Offline
        M Offline
        makumazan84
        wrote on last edited by
        #3

        Ha-ha) Probably you are right. In this case, what does "t" stands for? Most likely (bc it is an instance of T), this is from the first Terminator, the one that got smashed by Sarah Connor during the final battle inside the factory. Luckily, the author of that generic is not a fan of Aliens series )

        1 Reply Last reply
        0
        • A AspDotNetDev

          T2 was one of those rare movies where the sequel was better than the original. I understand what T1 and T2 are, but what is T? A prequel, perhaps? In any event, I'm glad they're making it with class. :)

          [Forum Guidelines]

          K Offline
          K Offline
          Kunal Chowdhury IN
          wrote on last edited by
          #4

          aspdotnetdev wrote:

          I understand what T1 and T2 are, but what is T?

          It's a typo... ;P I think, he was suppose to write T0 ... :laugh:

          Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.


          Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial

          1 Reply Last reply
          0
          • M makumazan84

            I've got a co-worker, who has done some great job in producing handsome and easy to understand pieces of code. The previos pearl was a 238 lines method, and when I asked to refactor it, he told that it was just fine. Still, this one is my favorite. (The name of the metHod is not that important)

            public void SendMetod(IEnumerable t)
            where T: class
            where T1: class
            where T2: class

            For some company issues I cannot post the method itself(a nice piece of work too, trust me), but it's header is adorable. T, T1, T2 and t is kinna brain explosive -- Modified Thursday, September 2, 2010 5:53 AM

            B Offline
            B Offline
            BillW33
            wrote on last edited by
            #5

            Finding good names for things is always difficult! I have seen names like T, T0, T1, T2. A truly odd pattern :confused:

            Just because the code works, it doesn't mean that it is good code.

            M 1 Reply Last reply
            0
            • B BillW33

              Finding good names for things is always difficult! I have seen names like T, T0, T1, T2. A truly odd pattern :confused:

              Just because the code works, it doesn't mean that it is good code.

              M Offline
              M Offline
              makumazan84
              wrote on last edited by
              #6

              Yeah ) From time to time I (and many other programmers) also got stuck when it comes to naming )) Probably, the part of the problem is that people who don't know generics usually google the first working example and rather often it uses such naming. To make things worse, Microsoft's MSDN website also "teaches" such generics namings. However, common sence should have won in my co-workers's case. Besides, he could have looked at other generics in that very same project, where type arguments are named like "TWrapper" or "TBaseObject" and thus bear some helpful info. Obvoiusly, exploding my poor brain with a whole bunch of T's wasn't a good option :-)

              B 1 Reply Last reply
              0
              • M makumazan84

                Yeah ) From time to time I (and many other programmers) also got stuck when it comes to naming )) Probably, the part of the problem is that people who don't know generics usually google the first working example and rather often it uses such naming. To make things worse, Microsoft's MSDN website also "teaches" such generics namings. However, common sence should have won in my co-workers's case. Besides, he could have looked at other generics in that very same project, where type arguments are named like "TWrapper" or "TBaseObject" and thus bear some helpful info. Obvoiusly, exploding my poor brain with a whole bunch of T's wasn't a good option :-)

                B Offline
                B Offline
                BillW33
                wrote on last edited by
                #7

                I have seen shops where they think that T1, T2, etc is poor naming. Instead their standard is to use T, U, V; a far better naming convention. ;)

                Just because the code works, it doesn't mean that it is good code.

                B 1 Reply Last reply
                0
                • B BillW33

                  I have seen shops where they think that T1, T2, etc is poor naming. Instead their standard is to use T, U, V; a far better naming convention. ;)

                  Just because the code works, it doesn't mean that it is good code.

                  B Offline
                  B Offline
                  BillW33
                  wrote on last edited by
                  #8

                  I didn't think I would get voted a 2 on my post. Maybe they didn't notice the wink? Or perhaps they like the T, U, V naming convention? :omg:

                  Just because the code works, it doesn't mean that it is good code.

                  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