Is there a name for this pattern?
-
From the stuff I work on:
Public Class ActionMessageList Inherits List(Of ActionMessage) End Class
Public Class CustomerList Inherits List(Of Customer) End Class
Public Class UserDayInformationList Inherits List(Of UserDayInformation) End Class
(Yes, those classes are all empty)
I just don't understand why this is almost everywhere.
-
i don't know if it has a name but where i've seen it used, at least where i let it live, was back when generics were new and debuggers reported List<X> as List types.
not too terrible but it made walking nested collections a pain in the backside because instead of getting X objects after querying in the debugger you got Object objects that you had to cast.
-
C/C++ programmer translating his
typedef
s?
-
Maybe one day you'd want to actually back the
CustomerList
with a hash table?Dunno, really. I've inherited collections when I had something to add to them, but seeing that the classes are empty... Maybe it's some extreme future-thinking.
-
I've done similar things before, but very rarely, and never just a simple reordering of words. The only reason I can think of doing it is so you can avoid typing out a massive amount of generics.
-
Maybe one day you'd want to actually back the
CustomerList
with a hash table?
That would be better done by encapsulation though.
-
That would be better done by encapsulation?
Tongue. Cheek.
Also, with encapsulation, you need to delegate
IEnumerable
calls and so on, and that sounds suspiciously like work.
-
The name is "junior without code-review"
-
I think the existence of this code is because the coder didn't ask himself "why", but rather "why not"
-
If this is part of a WPF application then it is because you cannot refer to classes with a generic type in them from XAML.
-
Those are from a few Libraries that are used in a Windows Forms application and an ASP.NET WebForms thingie.
-
the coder didn't ask himself "why", but rather "why not"
AKA proof by implementation.
-
If this was Java, it would be because generics are broken beyond usefulness for reflection, injection, lookup, etc. at runtime because TYPE ERASURE
-
C++
It does look like a translation of the C++ Curiosity Recurring Template Pattern (what do you mean, most C++ terminology is awful?)
In C++, it's a way to have polymorphism ('virtual functions') at compile time. I have no idea what it would be doing in what looks like Visual Basic.
-
What aliceif's found are not CRTP - they're just some weird wrapper types - no template parameters recur in their definition.
-
I did say:
look like
but yeah, I got nothing. I just wanted to hate on C++ for a little bit. Is that so terrible, huh?
-
Well, I didn't say I read your post carefully, so there's that.
But no, please feel free to hate on C++ anytime you wish.
As long as you like it secretly.
-
Me & C++, we got this thing... goin' on.
We both know that it's wrong...
-
- Avoid typing generics?
- Prettier inspection?
- ???
-
Me & C++, we got this thing... goin' on.
We both know that it's wrong...
I think I can do better than that:
Me and C++ got a thing goin' on, goin' on
Creepin' up slow, hangin' 'round my makefile, my makefile
If we get caught, everyone'll see us crash, see us crash
Me and C++ got a thing goin' on, goin' on
Sauce materiel
https://www.youtube.com/watch?v=3ZoKmdbERzA
-
Generally speaking, I would agree that this is foolishness - but it is possible that the developer had in mind that at some later date she/he might have to add some additional functionality to these lists, but wasn't smart enough to consider inventing something like MySuperList<T>...
-
Sauce materiel
Sigh. Do they teach you kids nothing of classic soul these days?
ME & MRS JONES by Billy Paul – 03:27
— discolarry124
-
If we get caught, everyone'll see us crash, see us crash
“If we throw an exception, everyone'll see us crash, see us crash”