Where do you keep Constants used throughout your application?

前端 未结 5 1206
小蘑菇
小蘑菇 2021-02-05 03:59

Is interface an acceptable place to store my

public static final Foo bar

Do you extrapolate them to be read from outside of the program? Do you

5条回答
  •  甜味超标
    2021-02-05 04:06

    This is bad practice. Classes are intended to be independent from one another therefore you should avoid global variables at all costs. A more realistic approach is to have a config file, usually in JSON, YAML, or XML file format, and have your program read from this file on start up.

提交回复
热议问题