How to Use C++ Dependency Injection to Write Maintainable Software - Francesco Zoffoli CppCon 2022

Sdílet
Vložit

Komentáře • 20

  • @babgab
    @babgab Před rokem +23

    "You don't need to have everything as classes to use dependency injection"
    THANK YOU. I wish this were known more widely.

  • @sword91ita
    @sword91ita Před rokem +6

    The way to explain interactions with geometrical figures is so clear and smart that should be used constantly in lessons, thanks!

  • @salahsoliman5752
    @salahsoliman5752 Před 4 měsíci +1

    Writing simple understandable code is much better than trying to achieve perfection.
    I don’t agree with the philosophy of this talk, but I enjoyed the fancy ideas.

  • @davidsicilia5316
    @davidsicilia5316 Před rokem +3

    great talk

  • @guilherme6535
    @guilherme6535 Před rokem +2

    Very nice talk.

  • @wolpumba4099
    @wolpumba4099 Před rokem +1

    Amazing!

  • @nintendoeats
    @nintendoeats Před rokem +7

    While that was interesting, it also made it clear to me that Francesco Zoffoli deals with a very different set of problems then I do. I can only think of a handful of places where this sort of added scaffolding would apply in my codebase, and those cases are already handled perfectly well by simple base* and runtime polymorphism.
    In essence, this seems very applicable to the sort of work one might do at Facebook; building behaviours that you expect other people to assemble like lego. I'm not convinced that the complexity overhead would be worthwhile for many smaller scale/less reusable projects (especially in my case where dependency on an external library already creates inherent coupling between many procedures and data structures).

    • @ChristianBrugger
      @ChristianBrugger Před rokem

      I am also curious about this. How are these things useful on a smaller scale.

  • @qazarl
    @qazarl Před rokem +5

    shared_ptr has constructor from unique_ptr, there's no point in returning shared_ptr from factory

    • @oysteinsoreide4323
      @oysteinsoreide4323 Před 8 měsíci

      As long as it is R-Value. Yes. That is correct. But will that make any difference?

    • @oysteinsoreide4323
      @oysteinsoreide4323 Před 8 měsíci +2

      I did some experimentation, and yes, a factory that returns a unique_ptr is more versatile if you want to use a unique_ptr on the client side of things. As a unique_ptr - R value can be assigned to a unique_ptr L-value. And a shared_ptr L-value can be assigned from a unique_ptr - R value.

  • @Nessaes
    @Nessaes Před rokem +2

    The factory whose given solution was to use a shared pointer.... it's just bad. The example was clearly bad designed, if the bufffilereader needs a buffer, he basically needs to own it, and hence to take a unique_ptr through a move. If he doesn't then a reference to the unique_ptr is fine (and then someone else has to own it, thus why instanciating in the clojure?). Last but not least, if bufffilereader interface supports legacy code via raw pointers, then a simple release() of the unique_ptr was sufficient.

  • @niklkelbon3662
    @niklkelbon3662 Před rokem +3

    Hm, why no type erasure? Its what you need

  • @batorygimnazjum2683
    @batorygimnazjum2683 Před rokem +2

    Reference member variables are usually a bad idea, I don't understand why the presenter recommends them. They remove default copy and move assignment. Storing raw pointers has identical utility and no such drawbacks.

    • @scatterarrow
      @scatterarrow Před 9 měsíci +4

      In my experience, any class that has pointers and references to other complex functional objects (not just data) is not something that should be copied and doesn't need to.
      And something that holds data should not and really doesn't need any access to (polymorphic) behaviors and has simple constructors.
      So, removing something you shouldn't have anyway is a good thing.
      Many programming languages nowadays start out with "data classes" or "record" etc

  • @privateerburrows
    @privateerburrows Před rokem +16

    Utterly inscrutable talk. No concrete example whatsoever; all abstract talk.

  • @glorioussir9673
    @glorioussir9673 Před rokem +7

    Title should be like "How to speed down compile time 100x"

  • @6eeykwr2
    @6eeykwr2 Před rokem +3

    Man the constant clicking noises he makes with his mouth is so annoying