I am now faced with integrating an inversion of control (IoC) container into an existing application, and I'm looking for some recommendations on how that can most easily be accomplished with the ultimate goal of reducing coupling, thereby increasing testability. Although I generally wouldn't classify most of the classes as god objects, each has too many responsibilities and hidden dependencies through statics, singletons, and lack of interfaces.
Here is a bit of background some of the challenges that need to be faced:
- Dependency injection is infrequently used
- Static methods abound - both as factory and helper methods
- Singletons are fairly prevalent
- Interfaces, when used, are not too granular
- Objects often pull in unneeded dependencies through base classes
Our intent is that the next time we need to make changes in a particular area, that we try to tease out dependencies which, in actuality, exist but are hidden behind globals such as singletons and statics.
I suppose that makes the IoC container secondary to the introduction of dependency injection, but I would expect that there is a set of practices and recommendations that could be followed or considered that will help us break out these dependencies.