Originally, in most languages, I would like to put constants into a class like that:
public class AppConstants{
public static final double HEIGHT_MAX=20.0;
public static final int COUNT_MAX=100;
public static final double WEIGHT_MAX=30.0;
}
but I found it is violating single responsibility principle, for example, some classes use HEIGHT_MAX
only, while the others may use both HEIGHT_MAX
and COUNT_MAX
but never use WEIGHT_MAX
.
So my question is, is it a good practice to define each class for each variable :
public class HEIGHT_MAX{
public static final double value=20.0;
}
public class COUNT_MAX{
public static final double value=100;
}
public class WEIGHT_MAX{
public static final double value=30.0;
}
so that a higher level class imports that class only when it requires that constant?