1. What are the steps we used to adopt constructor injection?
- We identified the dependency we wanted to extract and eventually inject.
- We removed the creation of that dependency and promoted it to a member variable.
- We then defined the abstraction of the dependency as a local interface and changed the member variable to use that instead of the real dependency.
- We then added a constructor with the abstraction of the dependency as a parameter so that we could ensure the dependency was always available.
2. What is a guard clause and when would you use it?
We defined guard clauses as a piece of code the ensured the dependency was supplied (in other words, not nil). In some cases, we used them in our constructors so that we could be 100% sure the dependency was provided.
3. How does constructor injection affect the...