The Factory Pattern - Mike Shah - CppCon 2021

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

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

  • @MikeShah
    @MikeShah 2 года назад +103

    Thanks for having me CppCon! I hope folks enjoy this pattern! :)

    • @superscatboy
      @superscatboy 2 года назад +2

      Thanks for the great talks, Mike!
      You're an asset to the back to basics track.

    • @janoskiss5335
      @janoskiss5335 2 года назад +1

      When I learnt about Factory Pattern the first thing came in my mind what Command and Conquer:) Awesome job Mate 👏

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

    Mike is a fantastic educator and I think if this talk was just in the back to basics track, and not the software design track, there would have been a lot less annoying nitpicky comments/“questions” from professionals with their egos hurt by being taught something they already know.

  • @Hamid1Reza
    @Hamid1Reza 2 года назад +1

    A great approach for mimicking somehow a virtual constructor in the abstract class and allowing for the run time object creation. I think using modern features of c++ like std::function, lamda, code injection (or the old feature, macro), we can make it more general. So that we can auto generate the required static members and methods. We also can generat various constructor intrefaces for the object.

  • @newoap
    @newoap 2 года назад +3

    Really enjoyed the talk Mike.
    You should do the State design pattern next as that is one I have trouble understanding😉

  • @Hav0c1000
    @Hav0c1000 2 года назад +1

    I tried to extend your fancy registration style factory pattern. I wanted just two things: 1. Don’t force the concrete create method to obey a fixed constructor function signature (use variadic template). 2. Use std::function…
    I flamed out miserably, perhaps because I was running on 5 hours of sleep and 3 cups of coffee…

  • @qm3ster
    @qm3ster 2 года назад

    My gripe is not with running interspersed updates and renders (which you admit is a problem) but with keeping all game objects as `Rc`.
    Wouldn't keeping objects of the same concrete type in individual dense non-dynamic collections (whether all together like in your prototype or split into Components within Systems) rather than a single collection of heterogenous dynamic objects always win?

  • @bryanlozano8905
    @bryanlozano8905 2 года назад

    Why was the singleton create method required? Wouldn't it be likely that one would create more than one instance of ant?

  • @nabeelsherazi8860
    @nabeelsherazi8860 2 года назад

    Is there any way in C++ to write this code using a generic like you might in C#? Like instead of Factory::Create(“ant”, 5, 5) could you do Factory::Create(5, 5) ?

    • @SkraxsChannel
      @SkraxsChannel 2 года назад +1

      template
      void MakeItComplicated(T* any)
      {
      any->compilcated = Factory::CreateComplicated(5,5);
      }
      Can also be done using concepts, if you want to be fancy.
      Or just ..
      Ant ant;
      ant.complicated = Factory::CreateCompilcated(5,5);

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

    I try with lambda is working well, better make it whole class as templates with function type or something like that.

  • @childhood1888
    @childhood1888 2 года назад +1

    41:47

  • @qm3ster
    @qm3ster 2 года назад +1

    Inheritance bad REEEEE

  • @nextlifeonearth
    @nextlifeonearth 2 года назад

    I honestly don't think this is a good example of a use case for the factory pattern. In games you're more likely to use(and you should probably use) an ecs.
    In what case it can be useful in in games is in combination with a state pattern. That's pretty much the only instance where we use factories in our real-time applications.