Environment variables in the constructor are a code smell
TLDR: don’t use env vars in class constructors. Seeing environment variables in a class constructor is a code smell and an anti-pattern. For example in TypeScript for Node.js, you might see something like this: Anti-pattern: class Foobar { private niceInjectableDependency: IDependency; private importantConfig: string; constructor(niceInjectableDependency: IDependency) { this.niceInjectableDependency = niceInjectableDependency; this.importantConfig = process.env.IMPORTANT_CONFIG; // code smell } } This might seem reasonable, as we’re still kind of able to inject the importantConfig into the class, just not via the constructor. Unfortunately this injectability is nowhere near as good as the usual kind with function call arguments.
NotesToSelf.Dev