Hi, I hope this isn't a duplicate. I did a search but there are a lot of dependency injection posts and I couldn't find any needles in the haystack.
So here's my question. I'm refactoring a class and adding a new dependency to it. The class is currently taking its existing dependencies in the constructor. So for consistency, I add the parameter to the constructor.
Of course, there are a few subclasses plus even more for unit tests, so now I am playing the game of going around altering all the constructors to match, and it's taking ages.
It makes me think that using properties with setters is a better way of getting dependencies. I don't think injected dependencies should be part of the interface to constructing an instance of a class. You add a dependency and now all your users (subclasses and anyone instantiating you directly) suddenly know about it. That feels like a break of encapsulation.
But this doesn't seem to be the pattern with the existing code here so I am looking to find out what the general consensus is, pros + cons of constructors vs properties. Is using property setters better?
EDIT: Wow, lots of useful answers in a really short time. Looks like the consensus is for the constructor.