I'm having some problems with using generics in combination with parallel class hierarchies. I have coded myself into this mess several times already.
Let's say I have the following class hierarchies: TableColumn -> subclasses SqlTableColumn, OracleTableColumn Table -> subclasses SqlTable, OracleTable Database -> subsclasses SqlDatabase, OracleDatabase
I use generics on the base types, which gives:
Table<TableColumn>
Database<Table<TableColumn>>
SqlTable<SqlTableColumn>
SqlDatabase<SqlTable<SqlTableColumn>>
OracleTable<OracleTableColumn>
OracleDatabase<OracleTable<OracleTableColumn>>
I have a feeling this is not a good use of generics. What would be a better design?