Because leaving the type parameter as it is not really dry. Consider this class:
class Muffin { List<string> _peopleWhoLikeMuffins = new List<string>(); public Muffin(List<string> peopleWhoLikeMuffins) { _peopleWhoLikeMuffins = peopleWhoLikeMuffins); } public void AddMuffinLiker(string p) { _peopleWhoLikeMuffins.Add(p); } }
It is very short and contains only basic functions, but I had to use the string parameter - genertic type - four times. And it will always be the same. And if I decide to switch to a type change later, I will have to replace all four occurrences.
In real-world scenarios, we are talking about hundreds, not four. So it is not a problem to always encapsulate it, but it is definitely worth considering.
Now my example is not very good (and not only because of stupid names), but you get the idea - you will have many declarations and instances of fields and variables, and every time you have to go through a type parameter that will always be the same in all codebase if your other classes are also common.
Another advantage of this is that you will have much less work if you ever need to add extra state / behavior to your collection.
With everything said, I myself do not use this abstraction very often.
Dyppl source share