Dependency Injection Smells
With the rise of dependency injection (DI) containers, which may or may not also be service locators, it is now very easy to keep track of all the dependencies of your classes and to switch between implementations. The temptation of using the new operator has since become much smaller. Still, all the options of the containers and locators, the syntax of the service definitions and lack of knowledge about design patterns related to dependency injection have resulted in some bad dependency injection design practices.
In this talk I will describe a couple of very recognizable and also very well fixable Dependency Injection Smells. After showing a code fragment which contains one of these DI smells, I will continue to work out different scenarios in which the situation gets out of hand and the smell becomes too bad. A solution then comes from existing design patterns and some general design principles.