Great C# generics naming [modified]
-
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: classFor 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
-
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: classFor 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
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. :)
-
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. :)
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 )
-
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. :)
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
-
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: classFor 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
-
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.
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 :-)
-
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 :-)
-
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.