Trying Another Way... (Dependency Injection)

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024

Комментарии • 24

  • @catalinim4227
    @catalinim4227 Год назад +1

    tech school has a really good series on microservices. I use that structure for all my go projects

  • @duongphuhiep
    @duongphuhiep Год назад +2

    Greate video, I didn't know this Fx library until now. As a C# developer. I remark a difference between this "Go Fx/DI" and "C#/DI".
    In C#, Java, we also use the DI framework to manage the "objects life cycle". For eg, when you "register" (or "provide") a "NewUserStorage", you will have to declare the "life time scope" of the "UserStorage" object after it is created. In C# the life time can be "singleton", "scoped" or "transient".
    * When you provide(NewUserStorage, "singleton") then the NewUserStorage() function would be called only once, then the created object "UserStorage" is re-use until the end of the application.
    * When you provide(NewUserStorage, "transient") then the NewUserStorage() function would be called each time a consumer need to resolve a "UserStorage"
    The Fx docs did not mention what is the life time scope of the provided object (I suspect that they are all transient?..)

  • @JohnDoe-ji1zv
    @JohnDoe-ji1zv Год назад +2

    Been using this for quite some time, and I would say that’s the way to scaffold servers or anything else in golang. Uberfx ftw

  • @arthuralvespsy
    @arthuralvespsy Год назад +1

    Hey Ben first of all, thank you about the video, I had some experience using the FX and for the specific project that I was working this looked like a Bazooka because behind the scenes it's using signals in a pool of objects inside the Context.

  • @coffeeintocode
    @coffeeintocode Год назад +2

    Nice 👌 never seen FX in use actually. Agreed though, lack of convention/opinion in Go is both a blessing and a curse

  • @Rgotto2
    @Rgotto2 11 месяцев назад

    Interface closures are nice as well.

  • @anselminos5238
    @anselminos5238 Год назад +2

    been using fx for a few months, i think it is great for dependency injection, although i wish it wouldn't log as much as it does by default.

  • @themarksmith
    @themarksmith Год назад +1

    Top quality video Ben

  • @SR-ti6jj
    @SR-ti6jj Год назад +2

    This is dope, very C#-esque

    • @ivan-penchev
      @ivan-penchev Год назад +1

      As an ex-C#er any time I see something like this I am remind of the talk by Dave in Gophercone on " Clear is better than clever "

  • @주영이-x3y
    @주영이-x3y Год назад

    nice video :)
    I have a career in Python and Java, and I honestly prefer the DI (Dependency Injection) pattern.
    Recently, I've been studying Go and it seems there's a lot of discussion about the DI pattern in the Go community.
    I have a question regarding this.
    When using frameworks or libraries that support the DI pattern in runtime environments like fx, dig, as far as I know, it involves using reflection, which I heard is an expensive resource in Go. I'm curious about what advantages you've gained using fx, compared to the aforementioned disadvantages.

  • @manee427
    @manee427 Год назад

    Thanks which software you use for drawing ? I mean the online app that can write like handwriting :)

    • @bmdavis419
      @bmdavis419  Год назад +1

      excalidraw

    • @manee427
      @manee427 Год назад

      Thanks and nice channel . keep going @@bmdavis419

  • @jeheskielsunloy3881
    @jeheskielsunloy3881 Год назад +2

    hey nice video mate, I was just wondering what is your vscode theme? i kinda like it

  • @josephmartin6219
    @josephmartin6219 Год назад

    You earned a sub man, thanks alot and please whats the name of the vscode font please, thank you!

  • @DevlogBill
    @DevlogBill Год назад +1

    Hi Ben, I have question? What backend technology would you recommend for me? I am from NYC so I have a good selection. I have about 1 year and a half experience in programming. Did 8 months in web development with HTML, CSS and JavaScript and very little experience with React. But I also have experience with Django and I am already making API's and I made 2 CRUD apps. But I am thinking about switching from Django to something else, there are hardly no jobs for Django. I check on indeed and I only see 2 or 8 jobs tops on a good day.
    Is Golang easy to pick up? I am assuming if I have already some very basic skills in a backend framework I hope learning another backend framework or library won't be as difficult.
    I would appreciate any recommendations, thank you.

    • @bmdavis419
      @bmdavis419  Год назад

      Its a borderline impossible question to answer, but I would say that if you are looking for a job TypeScript is gonna be your best bet. While I personally prefer Go, it has less jobs, and a smaller ecosystem, making TS both easier to pick up, and easier to get hired for. Once you learn TS though it is VERY easy to learn Go, C#, or any other high(ish) level language for BE. The concepts carry over nicely (REST, HTTP, SQL, etc)

  • @cariyaputta
    @cariyaputta Год назад

    What's the font you are using?

  • @esser50k
    @esser50k 6 месяцев назад +2

    do not use fx, please no. Dependency injection is a terrible idea.
    It breaks golang in so many ways.
    First you lose the compile time dependency checks, so it might compile and still not run.
    You might have code that is not even used. Go would usually catch that because you’d be initialising something and not using it. With fx you also lose that.
    Everything is a singleton, so to instantiate more than one object of the same type you have to wrap it in some bullshit..
    You totally lose sight of where your dependencies are coming from for your other constructors.
    I think it’s embarrassing for uber to put their name behind this shitty library.
    Just use plain go if possible. So much easier to just walk through your entrypoints, just a map from URL to handler and you build the app from there.. simple

    • @AndreasLimoli
      @AndreasLimoli 12 дней назад

      Even if I agree with you with the idea of "keep it simple", you are totally misunderstanding the idea behind dependency injection.
      Dependency injection is all about "passing dependencies (often via interfaces) instead of constructing them directly within a class or function".
      That's it! And this pattern is super maintainable, readable, and last but not least, testable.
      You cannot mix the concept of DI with a tool like fx or wire which implement this pattern in fancy ways.

    • @esser50k
      @esser50k 6 дней назад

      @@AndreasLimoli fair enough, just venting here because I have to deal with fx on the daily and its nothing but magic and problems, and magical problems