1.1. Why Generics?
Most programmers can point to that one moment in their career where the light of abstraction or generalization went off in their head. If you have a background in structured programming, this might have been uncovered during a foray into the world of function pointers. Or, maybe it just occurred to you one day when you discovered you could extend the functionality of one of your methods by parameterizing some aspect of its behavior. If you're from the OO crowd, this probably happened one day when you stumbled upon your first real good use for polymorphism. At that moment, whenever it was, you realized that goal of generality, extensibility, and reusability that everyone had been evangelizing.
Now, with generics, you have an opportunity to wrap your brain around another form of generalization. This new brand of generalization will provide you with a host of new concepts to toss into your proverbial bag of coding and design techniques. And, once you've mastered generics, you may find yourself wondering how you lived without them for so long.
To understand the fundamental value of generics, you really need to see a compelling example. Let's start with a sample of some code that you might write without generics. Suppose you've decided to write your own Pyramid Manager product that will allow you to track the relationships between each of the salespeople in a pyramid scheme. You need to start with a basic domain object that will hold the common attributes of each ...