Supercharge your Kotlin with Java Dynamic Proxies

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

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

  • @xxsaifxx2450
    @xxsaifxx2450 5 месяцев назад +1

    what a lovely video
    it's really nice to get inspired from these types of videos...
    your videos really helping me to develop large projects and making them easier to maintain, thanks to the algorithm for recommending me this video
    got a single question here about the proxy approach
    so in testing why we would use proxy object if we were going to test all the functionality of the object
    is it a temporary approach for this case so we can test some of the functionality and leave the rest later
    but I would not do that for the sake of seeing a compile error and handling it the way I want

    • @PairingWithDuncan
      @PairingWithDuncan  5 месяцев назад +1

      Thanks for your kind words. In testing we might use a proxy in place of a production object because it is easier to set up, or doesn’t launch missiles or somesuch - these are mock objects. In a couple of episodes’ time I think we will use a proxy that just slows down requests to the InMemoryCustomers in order to help test throughput. There are lots of places where we might want to augment existing functionality - see the decorator pattern.

  • @DavidWickes
    @DavidWickes 6 месяцев назад +3

    Nice! Inspired an entire afternoon of hacking around with proxy objects. Just wondering why you looked up the method on `this.java.class` rather than directly invoking the method that was passed to the invocation handler? It _seems_ to work the same for the scrappy one I've tested... but maybe I'm missing something?

    • @PairingWithDuncan
      @PairingWithDuncan  6 месяцев назад

      You can get away with the one passed to the invocation handler if your wrapped object implements the interface, but not otherwise?

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

      @@PairingWithDuncan Right - that makes sense - and because we were faking the structural subtyping you needed to look up the method from one interface into the other interface. Makes sense now!

    • @PairingWithDuncan
      @PairingWithDuncan  6 месяцев назад +1

      Next week's video shows that sometimes we have to look harder, down the back of the sofa, inside shoes, all sorts of places.

  • @i-am-the-slime
    @i-am-the-slime 6 месяцев назад

    Java has caused so much pain, suffering, and damage to the entire industry. I'd rather be writing COBOL or punch cards.

    • @PairingWithDuncan
      @PairingWithDuncan  6 месяцев назад +4

      Wow, that’s a bit extreme. Even if you would rather be writing something else, without Java there would be no JetBrains or Kotlin!
      Personally I find the language itself to be frustrating these days, but the JVM is an amazing technology and often the right tool for the job.

    • @jimmorrison2657
      @jimmorrison2657 6 месяцев назад +1

      I also don't use Java anymore, but it's a bit daft to diss it so much. If it was that bad it wouldn't have been the biggest language in the world for fifteen years.
      Duncan, how's it going? We used to work together at Sony with Richard Care. Jim Morrison.
      Great channel by the way.

    • @PairingWithDuncan
      @PairingWithDuncan  6 месяцев назад

      @jimmorrison2657 Wow blast from the past! I was, coincidentally, just chatting with Richard when I saw your message.

    • @jimmorrison2657
      @jimmorrison2657 6 месяцев назад +1

      @@PairingWithDuncan Aha, ok nice one. That's good to hear. All the best!!