• CodeBlooded@programming.dev
    link
    fedilink
    arrow-up
    7
    ·
    1 year ago

    Go programmer here: What does Go’s simplicity have to do with dependency injection? What does a language itself have to do with dependency injection?

    Reading your post and not being personally familiar with your work, I do wonder, perhaps your “extremely complex projects” wouldn’t be so extremely complex if you practiced dependency injection?

    How do you unit test your extremely complex projects if your business logic carries the additional responsibility of creating objects?

    • Ethan@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      1 year ago

      What does Go’s simplicity have to do with dependency injection?

      In my experience, following Go’s philosophy of simple solutions eliminates the need for complex solutions such as dependency injection.

      How do you unit test your extremely complex projects if your business logic carries the additional responsibility of creating objects?

      I write modular code that accepts interfaces so I can test the components I want to test. The vast majority of object creation happens at initialization time, not in the business logic. For the projects I’ve worked on, that would be true with or without DI - I don’t see how that’s relevant.

      perhaps your “extremely complex projects” wouldn’t be so extremely complex if you practiced dependency injection?

      When the CTO says, “Make it distributed and sharded,” I do what I’m told, but that is an intrinsically complex problem. The complexity is in the overall behavior of the system. If you zoom in to the individual execution units, the business logic is relatively simple. But the behavior of the system as a whole is rather complex, and DI isn’t going to change that.

      Edit: I was interpreting “using DI” to mean using a DI framework such as Unity, and I would be happy to never need one of those frameworks ever again.

        • Ethan@programming.dev
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

          Maybe I’m misunderstanding what “dependency injection” means. When I hear “dependency injection” I think of a DI framework such as Unity, so I thought “using DI” meant using one of those frameworks.

    • fuck_u_spez@lemmy.fmhy.mlOP
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      1 year ago

      I say it’s all about data flow and composability, if it’s pretty much always in one direction (modular tree structure/architecture) then you just don’t need all these “patterns”…