• xmunk
    link
    fedilink
    arrow-up
    6
    arrow-down
    2
    ·
    9 months ago

    I’d call this pattern a service factory approach given what’s being shown. Usually dependency injection hides the service specifics from the consumer. I’d say I want my class to have an iterator and some framework thing would assign a class to my constructor that fulfills that interface. This may seem like a pedantic point but at the level of distinguishing something as a dependency injection we’re getting down to the really fine grained distinctions… pretty much everything needs to do sort of the same thing (build services into other services) and the different approaches are really just about how we specifically do that.

    • Lmaydev@programming.dev
      link
      fedilink
      arrow-up
      3
      ·
      8 months ago

      Dependency injection is the actual act of allowing dependencies to be injected. Which this does.

      Creating a constructor that takes dependencies is DI.

      Using something to inject them automatically is more inversion of control.