For the great majority generics are something, revolving collections (and comparators..or was that TOO advanced?), made by Sun so everybody can use them later in their applications. Nobody seems to go one step beyond and try to develop generic classes of their own. Go figure!
So say we are designing a client application that needs to connect to several types of servers. A downright mediocre architect would write:
Generics to the rescue. Yes, you can do better! Believe me! That's what generics are really for. Not for collections but for you! For your designs! Let's refactor that interface of us a little. What would we need? Well, we know that a connection to the server is needed and that the server implementation and hence its connection are only known by the subclass in particular. So a FTP client has to return a different connection object that a Subversion client. Fine. Starting were our old good architect left the code we could try to modify it a bit. For example:
PS.- In case you're wondering where that code actually comes from I'm happy to announce that I've started a new Open Source project at Google Code: IWebJTracker. It's in its infancy right now but with time it will become an issue (project?) tracker built completely in Java. Think of Trac or Project Tracker. Why I'm doing it? For two reasons: first so IWebMvc has a poster child application, second because there are no good OSS Java issue trackers. And by good here I mean with good Maven integration..Sonar...Hudson...see where I plan to go?
PSS.- Any help is gladly welcome :-)