227 reputation
110
bio website
location Germany
age 34
visits member for 1 year, 11 months
seen Nov 14 at 8:27

Aug
25
awarded  Scholar
Aug
25
accepted Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
Aug
25
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
@Izkata No, this is not a matter of size. With the described approach, the code from that post would just be new ShippingService().
Aug
25
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
The fallacy is that zero-args constructible is not always possible - Yes, this is what is wrong with the approach in the question. The same argument is given in this answer.
Aug
25
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
Actually, just creating one object graph can already be tricky if collaborators are shared.
Aug
22
awarded  Self-Learner
Aug
22
awarded  Yearling
Aug
22
revised Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
clarify that I'm not questioning DI as a whole
Aug
22
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
there is an old, old ongoing debate - I don't want the whole debate, I just want the one supposed advantage "creating object graphs without DI is hard" explained. Other advantages of DI are out of scope in this question.
Aug
22
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
When I follow your argument, the reasoning for DI should have been "creating an object graph by hand is easy, but leads to code that it hard to maintain". However the claim was that "creating an object graph by hand is hard" and I'm only looking for arguments supporting that claim. So your post doesn't answer my question.
Aug
22
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
@Xion The dependency graph must be a directed acyclic graph. There is no requirement that there is only exactly one path between two nodes like in trees.
Aug
22
revised Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
add correct graph theoretic term for the "general dependency graph"; add more details how the approach in the question fails
Aug
22
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
Note that I'm not looking for other advantages of dependency injection - I'm only interested in understanding the argument that "object instantiation is hard without dependency injection"
Aug
22
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
abstracting downstream dependencies into interfaces - The example code does this too. The processor field is of type CreditCardProcessor, and not of the implementation type.
Aug
22
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
It doesn't. Just like BillingService, PayPalProcessor has a zero-args constructor which creates the collaborators it needs itself.
Aug
21
answered Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
Aug
21
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
Writing tests using a large part but not all of the dependency graph is in fact a good argument for DI.
Aug
21
comment Questioning one of the arguments for dependency injection: Why is creating an object graph hard?
The code would assume the responsibility of building all that out - A class only takes responsibility of knowing what its collaborator implementations are. It doesn't need to know what these collaborators need in turn. So this is not that much.
Aug
21
awarded  Student
Aug
21
asked Questioning one of the arguments for dependency injection: Why is creating an object graph hard?