Generics Mess
Sometimes, Generics can just cause a mess. Take for example the following definition I had to produce, just to get out of a Generified library I had somehow brought to life:
public final class PlayerFinishedAction<
TGame extends TurnBasedGame<
? extends Board,
TPlayer,
? extends Turn<Phase<TPlayer>>,
? extends Phase<TPlayer>>,
TPlayer extends TurnBasedPlayer>
extends DefaultAction<TPlayer, Location> {
You can only imagine the horrors inside a class defined that way. Needless to say, I had to re-evaluate the cost versus benefit that the generification of the library has brought to me.
I'd also like to highlight a previous post of mine about generified bi-directionality, and let it be reminded again that thanks to erasure, this is all in the end just a bunch of casts and overloads. What I mean to say is, make sure that the type-safety generated by the Generics mechanism is something of value and not just a nice touch, as it sometimes can make a simple application messier.
Comments (7)