C# Basic Observer Pattern Using Delegates

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ธ.ค. 2024

ความคิดเห็น • 23

  • @SirMika9
    @SirMika9 7 หลายเดือนก่อน +1

    I watch the whole playlist and it's excellent. The explanations are great and helps me a lot.

  • @Annimations
    @Annimations 4 ปีที่แล้ว

    This is an excellent demonstration of the observer pattern using delegates. Thank you!

  • @Tobadin
    @Tobadin 9 ปีที่แล้ว +14

    omg, my ears!
    Memo for me: No more wearing headphones, when listening to your classes O.O

  • @nizarabughannam6338
    @nizarabughannam6338 2 ปีที่แล้ว

    you are really a KING

  • @ThePancakeJedi
    @ThePancakeJedi 2 ปีที่แล้ว

    Wow. This video is 10 years old and still kinda relevant.

  •  11 ปีที่แล้ว +2

    Hi Jamie,
    Your tutorial is clear and very explicit. But I want to know more about this pattern: in Head First Design Patterns there is a complete section dedicated to this pattern but it is explain in Java, so I need to need if there are two equivalents to Observable class and Observer interface (java.util package)... is there?
    Thanks in advance for your response. ;)
    Regards from Bogotá (CO),

  • @oladipotimothy6007
    @oladipotimothy6007 6 ปีที่แล้ว

    This nailed it for me. Great content

  • @JamieKingCS
    @JamieKingCS  11 ปีที่แล้ว +2

    There is not. That is Java's way of making up for not having delegates. If you look at the Gang of Four, Java's implementation is very close to it. However, .NET cleaned this (often used) pattern up via delegates. It's a religious preference as to which one you use. Chaining delegates is an orthogonal feature. Look up Bruce Eckel's mp3 interview with Ander's on this topic. It is extremely enlightening.

  • @anhyeuvietnam
    @anhyeuvietnam 11 ปีที่แล้ว +1

    is the interview with Anders Hejlsberg? If it is I got the right audio then.

  • @JamieKingCS
    @JamieKingCS  11 ปีที่แล้ว +1

    Yes. I believe there are two.

  • @treasure2387
    @treasure2387 11 ปีที่แล้ว +1

    TrainSignal is a class that contains a delegate and a method that invokes the delegate
    Car is a class that takes TrainSignal as a parameter
    Car assigns the TrainSignal Delegate to it's private function StopTheCar()
    In main you create a TrainSignal instance
    You pass the Instance of TrainSignal to many Instances of Car
    That way the delegate of TrainSignal references a chain of StopTheCar fcts
    When the fct HereComeTheTrain is invoked all the fct stored in the delegate will run...

  • @egenesis1
    @egenesis1 10 ปีที่แล้ว

    Nice and easy way rather than implementing IObservable of T. However how do you Unsubscribe a certain object?

  • @treasure2387
    @treasure2387 11 ปีที่แล้ว +2

    //Observer pattern... dont know how to explain it. Watch this video again and again until you can express what is going on in words
    // A Delegate can reference a private method inside a class.
    // When you call that delegate the private method will run. This is very weird, but delegates are just compiler Aspartame

  • @Francisco-Gutierrez
    @Francisco-Gutierrez 5 ปีที่แล้ว

    Straight to the point, I like your style JK 👍

  • @mizantednioc
    @mizantednioc 5 ปีที่แล้ว

    THANK YOU !!!

    • @JamieKingCS
      @JamieKingCS  5 ปีที่แล้ว

      All you want

    • @mizantednioc
      @mizantednioc 5 ปีที่แล้ว

      @@JamieKingCS Can you make StopTheCar() method have parameters ?

    • @mizantednioc
      @mizantednioc 5 ปีที่แล้ว

      The answer is yes: public Action TrainsAComing;

  • @JosephR9
    @JosephR9 7 ปีที่แล้ว +1

    look like clasic events on c# :v

  • @luanau
    @luanau 5 ปีที่แล้ว

    Jamie is great but c# syntax is terrible here. We subscribe to the event by adding to the delegate!

  • @showbiz169
    @showbiz169 9 ปีที่แล้ว +4

    Great tutorial! Maybe don't speak so loud please? :)

    • @golfnutt1969
      @golfnutt1969 6 ปีที่แล้ว +5

      Your computer/phone/tablet should have a volume control to handle things like this. Try turning yours down.