The Observer Design Pattern in C++ - Part 2 of n - Extensibility and Abstraction

Поділитися
Вставка
  • Опубліковано 5 жов 2024

КОМЕНТАРІ • 13

  • @rohrbold
    @rohrbold Рік тому +3

    Great series Mike. I really love how you provide a step-by-step guidance from a naïve implementation to more sophisticated solutions. That’s a powerful way how students can better understand why the pattern ended up this way. Really inspiring, thanks a lot.

    • @MikeShah
      @MikeShah  Рік тому +1

      Cheers, thank you for the kind words! There's at least another 2 more episodes coming to continue building on the implementation 😀

  • @visitor_t-w3p
    @visitor_t-w3p 5 місяців тому +1

    Fantastic,....understood fully :)

  • @liteal
    @liteal Рік тому +1

    Oh hi. I saw this guy on the conference :)

  • @k0185123
    @k0185123 2 місяці тому +1

    Hello Prof. Shah, thanks again for your video! I watched your CppCon lecture about the observer pattern and the part 1 and 2 of the observer pattern on your personal channel. One thing that I've been thinking is what if we want those observers to communicate with each other? For example, the observer 1 tells observer 2 if the angry bird hit the stone, and the observer 2 use the final position and the velocity of the bird to see if it should become "multiple small birds". So, in this case, the observer 2 needs the input from both the subject and the observer 1. It'd be something like inheritance-based observer pattern? Is there such a design pattern? Thank you! :)

    • @MikeShah
      @MikeShah  2 місяці тому +1

      Observers can certainly 'observe' each other (i.e. one observe is the 'subject' of the other). If you think there's a lot of these types of dependencies, I might suggest some sort of 'event' system -- i.e. The observe posts events to some queue of 'hey this thing happened, now consume the event and do something with that data to create the small birds'. Check out 'event queues' or perhaps even the 'mediator pattern'

    • @k0185123
      @k0185123 2 місяці тому +1

      @@MikeShah Thank you so much for your help! I will look into them and see what I can do! :) Have a nice weekend!

    • @MikeShah
      @MikeShah  2 місяці тому

      @@k0185123 Cheers!

  • @valtovar
    @valtovar Рік тому

    Hi, really great series! Thanks for sharing this with the community. It would be good if you also talk about performance on each implementation. Is there any penalty in performance by using this approach with (virtual) interfaces? Are there other options that can work better in this regard? Can we use this code in, for example, the game main loop code?

    • @MikeShah
      @MikeShah  Рік тому

      Cheers, thank you for the kind words! Good idea, I think I'll touch on a few of those things in some later parts coming up 🙂

  • @TheGobou77
    @TheGobou77 Рік тому +1

    "Yes, I know you can't read this. You can download and read this later :)"