DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Why default values for environment variables should beΒ avoided
Omar for ClickPesa

Posted on

Why default values for environment variables should beΒ avoided

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

Top comments (0)

Find what you were looking for? Join hundreds of thousands of developers on DEV so you can:

🌚 Enable dark mode
πŸ”  Change your default font
πŸ“š Adjust your experience level to see more relevant content