However, not always instantiating a dependency in the constructor leads to a Control Freak anti-pattern, it depends on the nature of the dependency, as explained in the following.
There are two types of dependencies:
- Volatile: A volatile dependency is something that depends on the external world, it requires some environment setup, such as a database or network access. If it uses random numbers or depends on time, or when the dependency is not ready because it's still in development, it will eventually be replaced. An effect of a volatile dependency is that it creates strong coupling; if it doesn't let us test or extend the dependent class, it means it is volatile.
- Stable: A dependency is stable if it's already ...