I am sorry if this question was asked before, but I need a good suggestion to solve next design problem:
Task: given that we have a base service that operates with data of given set of types, we need to design support of extensions for that service that has extended type set.
Bad Solution:
class BaseServiceType {
public static final int TYPE_A = 0;
public static final int TYPE_B = 1;
public static final int LAST_USED_BASE_TYPE_INDEX = TYPE_B;
}
And its extension
class ExtendedServiceType extends BaseServiceType {
public static final int TYPE_E = LAST_USED_BASE_TYPE_INDEX + 1;
public static final int TYPE_F = LAST_USED_BASE_TYPE_INDEX + 2;
}
My task is fairly simple that has only one extension. I am not trying to solve more general problem with multiple independent extensions.
I have a feeling that enum
would work here, but no idea if it feasible.