[JAVA] Constant definition location guideline

Introduction

Here are some guidelines on where to define constants in your application.

Constant class

Example) Code values and fixed words used in the program Consider whether enums can be used When using it, be aware of the scope and create a constant class for each function or role. Do not create {system name} Constants.java. Avoid defining and using constants for an interface as it departs from the original purpose of the interface.

Property file

Example) Connection information (DB, each service, user ID, path), log output level, output destination (log, file)

DB (code table etc)

I was told, but I can't manage the version and I don't want to use it. The advantage of not having to re-release the application is talked about I don't think the application itself is cool because there are cases where you have to do so.

Environment variable


Reference link

How to manage constants Constant management location Criteria for determining where to place constants when creating an application. DB? File? [Java] Constant class that grows without thinking Properties file vs Constants class in Java

Recommended Posts

Constant definition location guideline
Java constant definition