Video Lesson - Static and Dynamic Binding

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

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

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

    I watched this video a couple of times when I needed to learn these for exams 8 years ago. Interestingly, last night the intro, "hey... sup" and "ello govn'r" expressions came to my mind. I had forgot your name sir, but I was remembering the video. Now I am here. Thanks for the lessons Mr. Quinn.

  • @1974rachavez
    @1974rachavez 3 года назад +16

    I love how good teachers try to get creative so students can pay attention. I know some of you don't see the relationship this teacher is trying to establish, but I do. Yo, yo, yo! That's a cool teacher!

    • @MrQuinnPhysics
      @MrQuinnPhysics  3 года назад +1

      Thanks so much, I really appreciate your comment!

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

    I love how your sense of humor into the lesson.

  • @dennish2238
    @dennish2238 7 лет назад +4

    This is an excellent explanation. Much better than my textbook.

  • @johnbritolima
    @johnbritolima 8 лет назад +74

    My first thought: "oh, no! he's trying to be funny."

    • @johnbritolima
      @johnbritolima 8 лет назад +32

      My final though: "I understood. Thanks!"

    • @MrQuinnPhysics
      @MrQuinnPhysics  8 лет назад +16

      Kudos on making it through to the end! I hope I didn't lose too many people in the first few minutes.

    • @JustkickinitG
      @JustkickinitG 7 лет назад +13

      It is refreshing to see someone teaching java development that isn't a complete square. Good job.

    • @MrQuinnPhysics
      @MrQuinnPhysics  7 лет назад +7

      Ben Morris-Rains Thank you! I'm glad that the explanation makes some sense!

    • @brunoribeiro1383
      @brunoribeiro1383 5 лет назад +1

      I had the same thought, but he got me at:
      hey, sup!

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

    This is great. Very clear to understand. Thank you very much.

  • @6xlord907
    @6xlord907 7 лет назад +3

    that intro is an instant thumbs up

  • @mostafasaber4491
    @mostafasaber4491 8 лет назад +26

    creative intro lol :D

  • @nileshdivekar3127
    @nileshdivekar3127 5 лет назад +1

    come to india
    we want a teachers like u

    • @kquinn85
      @kquinn85 5 лет назад

      Thank you for the invitation! I don't know if I could handle moving away from family, but if you are serious perhaps there are ways to partner remotely. I think it would be incredible to teach a multinational course through the internet!

  • @memorablename5187
    @memorablename5187 8 лет назад +3

    thanks mate a humorous insight into dynamic binding.
    never really caused me an issue in real wold programming but need it for an exam eh :)

  • @kaketoeter1951
    @kaketoeter1951 7 лет назад +1

    Thank you very much for the great explanation. I found it enjoyable to watch!

  • @dadaburro
    @dadaburro 8 лет назад +3

    I loved the intro.

  • @lathongher3179
    @lathongher3179 8 лет назад +2

    So static binding happens during compile time. Meaning in the main, test 1(q) will link back to Person q which will link to test 1 (Person x) {print (“Ello….”);}// It will print out “Ello Govenor”
    Dynamic binding happens during runtime (late binding). Meaning if we do “q.talk();” in the main method, it will then reference “q” as new student which will then link to the Student’s talk.
    Does it sound like I understand the differences between the two bindings?

    • @MrQuinnPhysics
      @MrQuinnPhysics  8 лет назад +2

      You got it! Compile time cares about the reference type and runtime cares about the instance type.

  • @madhubhargava5049
    @madhubhargava5049 8 лет назад +9

    Which of those two is static and dynamic binding?
    The one with q.talk() is dynamic.
    And the one with Test1(q) is static.
    Did I get it right?

    • @MrQuinnPhysics
      @MrQuinnPhysics  8 лет назад +19

      You got it! q.talk() is dynamic because at compile time the computer checks q's type (Person) and sees that it is ABLE to talk but at runtime when the command get executed the instance that q is pointing to (a Student) runs the code with its associated talk method.
      in the example Test1(q) there is a decision made at compile time to run one of two Test1 methods: the one that uses a Person or the one that uses a Student. Since q is a Person (by reference) the Test1 method that uses a person is chosen and is now statically bound. When you go to run the program it doesn't matter that q is ACTUALLY a Student because the decision to execute the Test1 method for a person had already been made at compile time.

    • @madhubhargava5049
      @madhubhargava5049 8 лет назад +2

      Kevin Quinn Thanks for the explanation. Really helpful. Hope to see some more great stuff from you...

    • @kquinn85
      @kquinn85 4 года назад

      @@sharifsircar my pleasure! Stay safe as well!

    • @kquinn85
      @kquinn85 4 года назад +1

      @@sharifsircar ha, no worries. I try to stay on top of comments and respond ASAP. Regardless, I appreciate the kind thoughts. We are one united world in this crisis.

  • @radiagulzan
    @radiagulzan 4 года назад +1

    nice explanation thank you !

    • @kquinn85
      @kquinn85 4 года назад

      My pleasure, glad you found it helpful

  • @AmeerHamza-cy6km
    @AmeerHamza-cy6km 3 года назад +1

    definitely not boring 😄 thanks..it was helpful

    • @MrQuinnPhysics
      @MrQuinnPhysics  3 года назад +1

      Glad you found it helpful AND not boring. Thanks!

  • @Moon-hr1fq
    @Moon-hr1fq 5 лет назад +1

    Thanks for the effort

  • @madawacko258
    @madawacko258 8 лет назад +2

    That was very helpful, thank you sir!

  • @MyDisal
    @MyDisal 5 лет назад +1

    this was really helpful, thank you

  • @grimsoul2free
    @grimsoul2free 8 лет назад +2

    Very well done, liked and subscribed!
    i just have one question tho, how would i know the methods that get invoked in the compile or the run ( i didn't understand this point) is it like every method that takes parameter will look at the dynamic type of the object ?

    • @MrQuinnPhysics
      @MrQuinnPhysics  8 лет назад +7

      The determining factor is whether you are looking at the REFERENCE or the INSTANCE. At compile time you only look at references. If we said "print( joe )" we are talking about the reference called joe. Suppose there are two print methods, one that takes a Person parameter and one that takes a Student parameter, the compiler chooses which one to run based on the type of REFERENCE joe is. Even if we had "Person joe = new Student()" at compile time joe is treated like a Person so the print methods that takes a Person is called. However, let's say in that method it said something like "joe.talk()". Since we are now de-referencing joe we are looking at what joe actually IS. Since he is an INSTANCE of Student that version of the talk method would be called.
      The best way to figure this stuff out is to make a sample program with lots of overloaded and overwritten methods. In each one simply put a print statement that says what method you are in. Then try different versions or calling methods with multiple combinations of references and you'll start to see the patterns emerge.
      Hope this helped clarify!

    • @grimsoul2free
      @grimsoul2free 8 лет назад

      +Kevin Quinn Many thanks sir! very well explained!

  • @mrhenry1112
    @mrhenry1112 8 лет назад

    Thanks for the video! good and clear explanation!

  • @peaceandpiesperson
    @peaceandpiesperson 8 лет назад +1

    Thank you !! Helped a lot :D

  • @alvinjesus100
    @alvinjesus100 8 лет назад +14

    Hey Sup!!

  • @COMB0RICO
    @COMB0RICO 7 лет назад +1

    Great teaching.

  • @MahmoudGamal-io3hl
    @MahmoudGamal-io3hl 4 года назад

    Thanks professor!

  • @madhubhargava5049
    @madhubhargava5049 8 лет назад +1

    Liked and Subscribed. Thank You.

  • @nileshdivekar3127
    @nileshdivekar3127 5 лет назад +1

    I am going to share this

  • @paritoshtiwari1584
    @paritoshtiwari1584 6 лет назад +1

    Awesome...want more on abstraction

  • @sereleg07
    @sereleg07 7 лет назад +1

    Muchas gracias Kevin :)

  • @edlodude
    @edlodude 5 лет назад +4

    r/fellowkids to the "hey, sup?"
    nah but seriously, great explanation!

    • @MrQuinnPhysics
      @MrQuinnPhysics  5 лет назад +1

      Thanks! I don't mind making a fool of myself if it will help get the point across

  • @fozlerabbishafi6036
    @fozlerabbishafi6036 8 лет назад +1

    Epic intro :D

  • @arushverma5144
    @arushverma5144 8 месяцев назад

    thank you

  • @kkmanmanR6
    @kkmanmanR6 4 года назад +1

    I clicked a timestamp and I realized that I skipped the interesting intro after reading comments.

    • @MrQuinnPhysics
      @MrQuinnPhysics  4 года назад

      Glad that you went back and got to see the intro!

  • @basselkordy8223
    @basselkordy8223 4 года назад

    Hey, Sup
    Great video :D

  • @TechnologyFighters
    @TechnologyFighters 6 лет назад

    Intro is very funny...surprising kinds of👌

  • @olof1
    @olof1 8 лет назад

    What I don't really understand is during run-time why the program can't see that person q is actually a student in this line: test1(q) and why it can see it when we're doing q.talk()

    • @MrQuinnPhysics
      @MrQuinnPhysics  7 лет назад

      Olof Enström In both cases test1(q) and q.talk() at compile time the program is ONLY checking to make sure the declared type can do what you are asking (static binding). However, with test1(q) there are overloaded methods. The compiler ALSO turns your computer code into specific instructions to be followed, one of those instructions being which version of the overloaded method to run. Since the compiler is only looking at the declared type and not the instantiated type q appears to be a person so the corresponding test1() method call is made. By runtime the instruction to run that version of the method gets executed. The funny thing is that if q is asked to do something like q.talk() that instruction is executed by the instance, in this case a student. Hope that clarifies, sorry for the delayed response!

  • @reoteuray9823
    @reoteuray9823 8 лет назад +1

    very good bro...

  • @anjanbabu1873
    @anjanbabu1873 4 года назад +1

    Where are you from sir

    • @MrQuinnPhysics
      @MrQuinnPhysics  4 года назад

      Hello Anjan, I am from Pennsylvania, USA

  • @eveilslayer
    @eveilslayer 6 лет назад

    He should have described those last method parts as interface types. Go language does this.

  • @jielyu4943
    @jielyu4943 6 лет назад +1

    hey, sup
    nice video!

  • @rahulsoni-lx5rb
    @rahulsoni-lx5rb 2 года назад

    🤩🤩🤩

  • @TheFlyguy31
    @TheFlyguy31 7 лет назад +1

    Spot on - I thought it was funny lol

  • @its_dropdead
    @its_dropdead 8 лет назад +3

    hey , sub !!
    you rock :D !

  • @EpicEditsBySaz
    @EpicEditsBySaz 7 лет назад

    So then why can't we just use the line of *Student q = new Student* intstead of using *Person q = new Student*, so that we don't have to deal with that problem you mentioned at the end, with the Test1(q) method.
    Btw thank you for the video! I have an oop quiz tmrw afternoon :/

    • @MrQuinnPhysics
      @MrQuinnPhysics  7 лет назад +1

      You can! This is really a question about "polymorphism", meaning that you can refer to an object many different ways. Sometimes it is inconvenient but other times it can be a huge help. Imagine for example a car dealership that wants to keep track of its inventory. You might do so with an ArrayList of type Car. However Car is more general than FordTaurus, FordF150, and FordFiesta. Each of these specific types of cars might have special methods but it is way more convenient to treat them all like Car objects so they can be in one list.
      At a school you might have a similar example where you keep a list of Person objects, but in that list you may have Student, Teacher, and Parent objects. There could be an advantage to one vs three lists. That is a design decision, but you need to understand the technical implications in order to make a good decision.
      Hope that clarifies!

    • @EpicEditsBySaz
      @EpicEditsBySaz 7 лет назад

      Wow thanks for responding! Esp before my test tmrw! :D
      Oh i see, so like you could have an Array of type class Car, but inside have different subclasses but with super-class being Car?

    • @MrQuinnPhysics
      @MrQuinnPhysics  7 лет назад +1

      Sadeq You got it. it's very common to have one data structure, like an ArrayList, full of different stuff. Technically you could always just declare things as objects, but to your original point it's better to be as close as possible to the actual object so you can use the locally defined methods.

    • @EpicEditsBySaz
      @EpicEditsBySaz 7 лет назад

      Thank you! :)

  • @sophiabnrm8730
    @sophiabnrm8730 6 лет назад +1

    This was very clear. But I still have a question:
    What if only class Student has a method test1(Student x). Now I call test1(q). Since you said, that I get the test1() method from class Person, what happens when there is no such method in class Person only in class Student?

    • @MrQuinnPhysics
      @MrQuinnPhysics  6 лет назад

      Great question! If there is no such method as: test1(Person x){ System.out.println("'Ello Govn'r"); } then a call to test1(q) will generate a COMPILE time error. As far as the compiler is concerned test1( ) can only be called with Student objects and since q is referenced as a Person object the compiler will through a type mismatch error even though at RUNTIME q would be treated like a Student because that is how it is instantiated.
      Think of it this time. Suppose I taught you how to put down the roof of a convertible car. That would be like writing a method takeOffRoof(Convertible c){...}. Now, if I told you "put down the roof on that CAR" you'd probably assume the car is ACTUALLY a convertible, because if it were not you wouldn't be able to put down the roof. A compiler cannot make that assumption though so if I wrote the code:
      Car c = new Convertible( );
      takeOffRoof( c );
      I will get an error at compile time because the compiler can't find a method that knows how to take off the roof of Car objects. The following code, however would work:
      Convertible c = new Convertible( );
      takeOffRoof( c );

  • @terryn9450
    @terryn9450 6 лет назад

    well, I mean great presentation, except you didn't tell us which one is which.. I had to go watch another video to actually know which one is static and which is dynamic. Nevertheless, a good explanation without the actual labeling of ur explanation.

  • @source144
    @source144 5 лет назад +1

    Hey sup

  • @ericandrade3510
    @ericandrade3510 6 лет назад +1

    Hey, sup?

  • @lucidemon
    @lucidemon 7 лет назад +1

    Marry me!

  • @GeorgeNavarro
    @GeorgeNavarro 8 лет назад

    Sup