1. How does Just-in-Time (JIT) dependency injection differ from constructor injection?
This depends a lot on how the constructor injection is being used; in particular, how many different implementations of the dependency exist. If there is only one production implementation of a dependency, then they are functionally equivalent. The only difference is UX (that is, whether there is one less dependency to inject into the constructor).
If, however, there is more than one production implementation, then JIT dependency injection cannot be used.
Â
2. When working with optional dependencies, why is using a NO-OP implementation important?
When a member variable is not set by the constructor, then it is effectively optional. We cannot, therefore, be sure that the value has been set and not nil. By adding a NO-OP implementation of the optional...