A good reason why this should not be done is that you cannot force a subclass to execute a specific constructor. This is very obvious for the implementation of the interface, since they do not include a contract for designers.
And if your real or abstract BaseTable class had a BaseTable(int columns) constructor, a dummy VectorTable subclass with one column would not have to implement it and could do something bad, for example
public VectorTable(int intialValue) { super(1); this.initialValue = initialValue; }
So, you donβt know if T implements the constructor at all, and secondly, you donβt know if the constructor has the same goal (which it really should have in the correct code !!)
So, the best solution is to move the parameterized part from the constructor to a separate (final?) Method, create an instance with the default constructor and immediately call this initialization method.
You might consider implementing a BaseTableFactory if you want to make sure that all subclasses of BaseTable are always initialized correctly.
Edit
And new T() (instantiating the default constructor) is also impossible, since no class can be forced to be implemented by the available default constructor. I still think the factory pattern is your best friend here.
source share