At this point, all of our classes and functions have been consolidated to a central location, and all related include
statements have been removed. We would prefer to start writing tests for our classes, but it is very likely that we have a lot of global
variables embedded in them. These can cause a lot of trouble via action at a distance where modifying a global
in one place changes its value in another place. The next step, then, is to remove all uses of the global
keyword from our classes, and inject the necessary dependencies instead.
Note
What Is Dependency Injection?
Dependency injection means that we push our dependencies into a class from the outside, instead of pulling them into a class while inside the class. (U sing global
pulls a variable into the current scope from the global scope, so it is the opposite of injection.) Dependency injection turns out to be very straightforward as a concept, but is sometimes difficult to adhere...