Question on refactoring and code design
Posted
by
Software Engeneering Learner
on Programmers
See other posts from Programmers
or by Software Engeneering Learner
Published on 2012-11-15T15:11:03Z
Indexed on
2012/11/15
17:22 UTC
Read the original article
Hit count: 487
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?
© Programmers or respective owner