4 ms·
Sorry, perhaps I should have been a little clearer. What I meant is that you don't need to figure out the order in which you have to construct the dependency t
by eeperson 7y ago
Sorry, perhaps I should have been a little clearer. What I meant is that you don't need to figure out the order in which you have to construct the dependency tree. The order of the tree itself (as in what depends on what) is something you still need to specify and should know.
EDIT - You have a tree of dependencies. This is something you care about. In order to create that tree in code, you have to convert it to a linear series of statements. This conversion is something you don't really care about as long as you end up with the tree you want. Dependency injection frameworks should make it so you can declaratively specify that tree without having to worry about how it is actually constructed.
- sagichmal 7y agoThis doesn't really make sense to me. The dep graph is a second-order thing, a conceptual model that's emergent from the parameters to the imperative constructors. It's not a first-order thing that we manipulate directly. There's no way to even represent a graph in a text file without flattening it to some order, anyway. The point being made is that just writing the construction statements in the main method is exactly "declaratively specify[ing] that tree", and that "having to worry about how it is actually constructed" is incredibly valuable knowledge to maintainers, because it allows them to see explicitly how components are constructed, and how they interact with each other. It's not something you want to hide with a framework, it's something you want to lift up, front-and-center, so everyone can see it.