Having recently discovered dependency injection I'm now trying to get to grips with how often and how far to take it.
For example, let us say that I have a dialog which prompts a user for their registration details - first name, last name, telephone number, a serial number - that sort of thing. The data should be validated in various ways (e.g. that the first and last name aren't empty, that the serial number is a certain length). Once validated, it should be cached on the local machine and also sent to a registration server. The dialog should only close once all of those things succeed, or the user cancels.
So that's maybe four things we're trying to achieve here (responsibilities): UI, validation, local caching, sending data to a non-local server.
What is the dialog's responsibility and what should be injected? Obviously the dialog does the UI, but should validation, caching, and data sending all be injected? I'm thinking they do, otherwise the dialog class has to know about the logic behind the data fields in order to do validation, it has to know how and where to cache data, and also how to send the data somewhere. If so, this can lead to some hefty code at the caller's end (assuming we're doing injection via the constructor, which I think is preferable to setter functions), e.g.
MyDialog dlg(new validator(), new cacher(), new sender());
But perhaps that's ok? It does look a little alien to me right now after years of seeing code where things like the dialog do everything. But I can also see how this escalates quickly - what if there are all sorts of other small things it needs to do - how many things being injected becomes "too many"?
Please don't try to pick holes in the example scenario, I'm just using it for illustration. I'm more interested in the principle of DI and at what point you may be taking it too far.