Suppose that you have a Java project with several classes, most of them dealing with some constants (properties of your dataset, which are supposed to be loaded (based on your dataset) at the beginning of your experiment).
To become able to access these constants in the entire classes, a very reasonable option is putting the constants as fields of a container (object/class/Interface). Then for letting your other classes take advantage of the container field, you have 5 ways
Only if the field is dynamic:
- passing the container to the dealing method (the method which deals with required constants)
- putting the container in a field of the method-class (the class which your method is located in).
Nevertheless of the field being dynamic or static (when the container is a class)
- extending the container of that field by the method-class.
Only if the field is static
- implementing the container of that field by the method class.
- calling the static fields (Container.field)
The first two options and the last one force you to write in your code tens or hundreds of time the container name + '.' (e.g. container.trainingListSize, container.numberOfUsers, Container.trainingListSize, Container.numberOfUsers, ...) which I am trying to get rid of that; the third option forces you to be the son of a special class which sometimes contradicts the structure of your program. It remains only the last option; but unfortunately in Java interfaces the constant values of interfaces are final and cannot be set, when you load your properties file, at the beginning of the program.
Looking at the question (Variables in Interface), it seems that the questioner was in a condition like me; but yet no solution I found.