In every application, you will have at least a few configuration items that you might not want to hardcode. Instead, you want them to change in the future, after the application goes live, without touching the code.
In general, I would classify configuration items into two categories:
- Some configuration items might be different across environments, for example, the connection strings of the database and SMTP server
- Some might be the same across environments, such as some constant numbers that are used in code calculations
Whatever configuration values are used for, 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.