I have a class that serves as a wrapper for a specific table within a database. Within the constructor of this class (let´s call it MyLookup
) we make some initialization (e.g. reading some metadata). Now I am supposed to create a second table within the database which is more or less a copy of the first.
class MyLookup {
public const TABLE_NAME = "MYTABLE";
private readonly ITable table;
MyLookup() {
this.table = OpenTable(TABLE_NAME);
/* further init */
}
}
The problem is that the code for initialization is more or less the same as of the "base"-table. only difference is its actual name. Usually I´d just change the constant TABLE_NAME
to become a virtual property that can be overridden within my derived table-class. But that const may be used within legacy code hence changing it to a property would lead to also changing its access (instance instead of static). So how may I call the base-initialization with a different TABLE_NAME
by only making least changes to MyLookup
?