Question on refactoring and code design
- by Software Engeneering Learner
Suppose, I have a class with a constant static final field. Then I want in certain situations that field to be different. It still can be final, because it should be initialized in constructor. My question is, what strategy I should use:
add this field value into the constructor
create 2 subclasses, replace original field usage with some protected method and override it in subclasses
Or create some composite class that will held instance of my class inside and somehow change that value?
Which approach should I use and why?