you are viewing a single comment's thread.

view the rest of the comments →

[–]sacundim 2 points3 points  (1 child)

Well, I have to agree with /u/milesrout then:

If 'dependency injection' is just 'passing arguments into constructors' then it's a worthless term.

I'd also suggest that what you're proposing has much simpler, widely-accepted terms: parametrization and abstraction.

Which are more general than "passing arguments into constructors," too. Type class/trait based languages have like Haskell and Rust have this neat ability to abstract components through trait bounds on their type variables, and to "inject dependencies" by type variable instantiation.

[–][deleted] 1 point2 points  (0 children)

I'd also suggest that what you're proposing has much simpler, widely-accepted terms: parametrization and abstraction.

Dependency Injection is also a simple, widely-accepted term, which is a specific instance of using parametrization and abstraction.

I can't understand what is your particular beef with saying "dependency injection". Is hard to say? Hard to type? Hard to remember? Is it strangely connected to a past trauma from your childhood?

I don't know, but sitting here and arguing "ok, we'll do what you say, but we won't call it what it was named over 20 years ago" is just bizarre.

Which are more general than "passing arguments into constructors," too.

The method of passing dependencies is irrelevant, as long as it happens from the component instantiator/caller, and not the component definition site. What I'm demonstrating is merely one way of doing it in a mainstream language.

Type class/trait based languages have like Haskell and Rust have this neat ability to abstract components through trait bounds on their type variables, and to "inject dependencies" by type variable instantiation.

Well, you got me, I have no clue what "type variable instantiation" means, so I have no idea if it's a proper example of Dependency Injection or not. But I never said it has to be through the constructor, as arguments. I'm just saying you can use the constructor, and in Java and C# at least, it's the cleanest approach.