Use properties file instead of static final variables

后端 未结 6 1502
轮回少年
轮回少年 2021-02-08 03:05

I have many classes with static final fields which are used as default values or config. What is best approach to create global config file? Should I move these fields to single

6条回答
  •  余生分开走
    2021-02-08 03:39

    As for me, the main difference between the approaches is an ability to change values without changing a code.

    With static final fields you must recompile sources to use new values. With .properties files you just usually have to restart an application that may be done by system administrator etc.

    So it seems to be a matter of whether it should be changeable or not and whether it should be available for someone except a developer. (In some sense it's a questions who is "in charge of" these values: developer or system administrator/user etc.)

提交回复
热议问题