Generics and object collections
In VS2003, since we don't have generics, we have lots of strongly-typed collections.
For example, there's the LinkCollection class, which holds objects of type Link.
Now that we have generics, we could replace such collections with:
List<Link>
(well, actually, we couldn't replace them, as that would break existing code, but
we could do that for new collections). That seems like a simple solution, but it isn't
optimal, for a couple of reasons:
1.
Sometimes the type in the collection isn't sufficiently distinctive, especially if
it's a built-in type. You'd like to see something like EmployeeIDCollection rather
than List<int>
2.
It's often useful to add additional functionality to the collection beyond what you
get from the built-in collection class.
The better solution is to define your own collection class. Nicely, you can base it
off of the collection class:
class EmployeeIDCollection: List<int>
{
...
}
The design guideline is not to expose collection classes, but rather to expose custom
collection classes (I really need a better name for those) instead.