I have some abstract class, in one of its method I use a string field which is supposed to be specific to the subclasses. I wonder what is the bect practice to implemnet this? via field and setting the field value in a consructors of the subclasses? via a static field and changing the value in every subclass?
What would you suggest?
The subclasses should specify the value. The superclass should define it’s interface. Use the template method design pattern.
Example:
Another option is to set it in the constructor: