It was obvious as hell from day one of generics that there will appear obscure long names when you will start to parametrize your types. It was the easiest thing in the world to take care of this in advanvce. Alas, C# inherits C++'s bad practices.
Read Associative containers in a functional languages and Program.cs to see what we're talking about.
Briefly, there is a pair (string, int), which in C# should be declared as:
string
int
System.Collections.Generic.KeyValuePair<string, int>
Obviously we would like to write it in a short way. These are our attempts, which fail:
1. Introduce generic alias Pair<K, V>:
using System.Collections.Generic; using Pair<K, V> = KeyValuePair<K, V>;
2. Introduce type alias for a generic type with specific types.
using System.Collections.Generic; using Pair = KeyValuePair<string, int>;
And this is only one that works:
using Pair = System.Collections.Generic.KeyValuePair<string, int>;
Do you think is it bearable? Well, consider the following:
ValueNode<T>
T
Pair
TreeNavigator<N>
N
ValueNode<Pair>
The declaration looks like this:
using Pair = System.Collections.Generic.KeyValuePair<string, int>; using Node = NesterovskyBros.Collections.AVL.ValueNode< System.Collections.Generic.KeyValuePair<string, int>>; using Navigator = NesterovskyBros.Collections.AVL.TreeNavigator< NesterovskyBros.Collections.AVL.ValueNode< System.Collections.Generic.KeyValuePair<string, int>>>;
Do you still think is it acceptable?
P.S. Legacy thinking led C#'s and java's designers to the use of word "new" for the object construction. It is not required at all. Consider new Pair("A", 1) vs Pair("A", 1). C++ prefers second form. C# and java always use the first one.
new Pair("A", 1)
Pair("A", 1)