In every application, you will have at least a few configuration items that you might not want to hardcode. Instead, you would want them to change in the future, after the application goes live, without touching the code.
In general, I would classify the configuration items into two categories:
- Some of the configuration items might be different across environments, for example, the connection strings of the database and SMTP server
- Some of them might be the same across environments, such as some constant numbers that are used in some calculations in the code
Whatever might be the use of the configuration value, you need to have a place to store them that is accessible to your application.
In this recipe, we will learn how and where to store these configuration items and different techniques to access them from your application code.