Assuming you expect a particular variable to be present, what should you do if it is not present? I say stop the application immediately.
Based on my experience, default values are the root of almost all evil in development. If you provide default values, means you do not care about the supplied value because you can at any time substitute it with something else.
It means you do not care about the supplied value because you can at any time substitute it with something else.
It is also a good practice to always split configuration from code.
Default values can make debugging a misconfigured application more difficult, as the final config values will likely be a combination of hard-coded default values and environment variables.
Relying purely on environment variables (or as much as possible) means you have a single source of truth for how your application was configured, making troubleshooting easier.
If you enjoyed this story, our blogs have more like it. Checkout dev.to/clickpesa, medium.com/clickpesa-engineering-blog or clickpesa.hashnode.dev
Oldest comments (0)