Possible Duplicate:
Dependecy Hell - how does one pass dependencies to deeply nested objects
Lately I've been struggling with this particular problem. For testing and managing reasons I decided it would be a better option to inject an object like $config to those who need it. While at start it was ok, later it started polluting the code. For example: Object A uses object B to do its job, object B uses strategy object C, object C uses object D, which needs $config object. So, I have to keep passing $config down this whole chain
In my code I have two objects like that to pass through, which makes constructors big, having duplicated code and generally it smells wrong. I would appreciate any help in refactoring this relationship.