Common Java Skill : Multiple Return Values like Go 🚀 |

Поділитися
Вставка
  • Опубліковано 7 січ 2025

КОМЕНТАРІ • 74

  • @ascar66
    @ascar66 4 місяці тому +7

    We used to create our own pair classes to use in project. Now it's cool to have ready to use libs. Thank Techie

  • @manoganesan7618
    @manoganesan7618 4 місяці тому +2

    I have implemented this concept in one of our existing methods after watching your video. You are awesome!

  • @gopisambasivarao5282
    @gopisambasivarao5282 4 місяці тому +2

    Appreciate your efforts Basant! God Bless you!🙏👍

  • @jaganathanmurthy6861
    @jaganathanmurthy6861 4 місяці тому +1

    Thanks buddy. Every time i got a notification from you , got curious to learn new thing to build my carrier growth.

  • @smacdonald2012
    @smacdonald2012 4 місяці тому +3

    Return a list of POJOs. Another way to implement this. Like in all languages, different ways to perform such tasks.

  • @MrKKPA
    @MrKKPA 4 місяці тому +5

    What might be the benefits of adding a library to do that when you can achieve the same by creating a object that contains the others nested objects?

    • @raghavanaliassaravananm1546
      @raghavanaliassaravananm1546 4 місяці тому

      Good Q. But you may not have a consistency of marking the objects as Left, Right or Middle. Of course Apache Commons Lang made the trend with this I suppose. In your custom classes, it would be more obvious to think of using a Map but that has its own variants.

  • @jrdillip
    @jrdillip 4 місяці тому

    Thank You Basant Bhai, I was not aware about these fantastic classes. Thank you for sharing it, now I will try to use this in my project.

  • @soto5987
    @soto5987 4 місяці тому +16

    Please do not use this, the readability is so much lower. Multiple return values are a sign of too much responsibility or a lack of domain understanding. We create on purpose objects that hold values to communicate intend or coupling.
    In Go we use them to return value, error that is a totally different approach.

    • @abhiroopghatak9442
      @abhiroopghatak9442 4 місяці тому +1

      *it is very useful but not for domain object ........but think it returns domainObject and possible exception object...
      and receiver will have either successful response from service or its internal exception which it need to refine more before showing to user.
      Pair

  • @saim7281
    @saim7281 4 місяці тому

    Please do the video on remove duplicates in custom objects by using key using java stream api.
    Your videos are so boosting up my skills a lot.Thank you so much

  • @kanaillaurent526
    @kanaillaurent526 4 місяці тому +20

    Why not just return a record?

    • @inzi27
      @inzi27 4 місяці тому

      what if you need to return multiple records?

    • @kanaillaurent526
      @kanaillaurent526 4 місяці тому +2

      @@inzi27 put your records into a single record. and return this single record.

    • @darogajee3286
      @darogajee3286 4 місяці тому

      Can you explain with code

    • @magdel1940
      @magdel1940 4 місяці тому

      Same question.

    • @NaveenMovva
      @NaveenMovva 4 місяці тому

      Nested records pattern is supported from java 21

  • @devaamujuri5998
    @devaamujuri5998 4 місяці тому +2

    Hi Basant, I need some suggestion regarding one of the requirement.
    I need to reterieve the data one of the database table, it has morethan 3 lakhs records (for first time), 1. I need to call some 3rd party API for each rows and get some relavent details from API resonse and then I need to update same row with other 2 fields. So how we can handle entire thing in same request and wtih in same end point. (bascially retreive data, do same change in row, update same row for those many records).
    2. This can be run on weekly batch. ( may be first time 3lakh records, later batch run it might be less), based on flag in DB column we can identify allread processed or not processed rows.

    • @Javatechie
      @Javatechie  4 місяці тому

      Please drop an email to javatechie4u@gmail.com and elaborate your usecase little bit

  • @abhijitprusty
    @abhijitprusty 4 місяці тому +1

    Awesome contents....

  • @El_Espada
    @El_Espada 4 місяці тому +3

    Kotlin has this feature and I find it awesome.

  • @raghavanaliassaravananm1546
    @raghavanaliassaravananm1546 4 місяці тому

    Interesting Video. Thanks for sharing Basant.

  • @samsneera
    @samsneera 4 місяці тому +1

    How will this be useful if the number of objects to be returned are more than three?
    Considering readability and convenience, this feature looks good. As per my understanding, we can come up with our custom class containing these multiple records to be returned.

  • @gouravkumar-or6jy
    @gouravkumar-or6jy 4 місяці тому

    Thanks sir to share this knowledge 🙏, even though i used Pair class many times in my code.

  • @saravanasathish423
    @saravanasathish423 4 місяці тому

    This common lang3 will reduce writing multiple methods, thanks for the info ❤

  • @rudrajitgupta3688
    @rudrajitgupta3688 4 місяці тому

    This was awesome Basant..thank you for the learnings

  • @Nilcha-2
    @Nilcha-2 4 місяці тому

    Though this makes it more object oriented, in the old days I use pass such object by reference to the method arguments. You can send back more than 3. Only it is mutable and open to side effects.

  • @phanimc11211
    @phanimc11211 4 місяці тому

    thanks as always very resourceful

  • @phoenixjones0804
    @phoenixjones0804 4 місяці тому +1

    Great content Basant bhai, next video tike kafka connect upare kara. Searched a lot but couldn't find anything useful with real life implementation. Jay Jagannath

    • @Javatechie
      @Javatechie  4 місяці тому +2

      Okay noted Sritam ✅️.

  • @kachoutmohamed9492
    @kachoutmohamed9492 4 місяці тому +2

    Can use RECORD !?

  • @abhuzaifa
    @abhuzaifa 4 місяці тому +1

    @java techie please make a playlist on java 9,11
    features

  • @shankarraojujjuri9408
    @shankarraojujjuri9408 4 місяці тому

    nice information, I created custom pair class in my project, we will use this feature next onwards in my project

  • @MurariKumar-wp6td
    @MurariKumar-wp6td 4 місяці тому

    Thanks.. it is very useful for developers ❤👍

  • @maheshwer007
    @maheshwer007 4 місяці тому +5

    We can use pojo class instead, which would be more cleaner and easy to understand approach, this approach creates confusion for new devs

  • @BaluKompalli
    @BaluKompalli 4 місяці тому +1

    Wow.... 🎉🎉🎉🎉🎉

  • @harichebrolu2817
    @harichebrolu2817 4 місяці тому

    Useful concept

  • @MilsonDev
    @MilsonDev 4 місяці тому

    Nice feature.

  • @abhinetrakumar
    @abhinetrakumar 4 місяці тому

    Thank You Sir ❤❤

  • @mohammadtoficmohammad3594
    @mohammadtoficmohammad3594 4 місяці тому +1

    Thank you

  • @manishkeshari5096
    @manishkeshari5096 4 місяці тому

    Thank you it's helpful ❤

  • @sushant6815
    @sushant6815 4 місяці тому +1

    Great

  • @girishanker3796
    @girishanker3796 4 місяці тому

    Great to know

  • @saichaithanyasaraf7634
    @saichaithanyasaraf7634 4 місяці тому

    Why we need this when we have hashmap? @Javatechie

  • @rajkumarwinc9372
    @rajkumarwinc9372 4 місяці тому

    Can we return more than 3 different objects..

  • @ErfanHossainShoaib
    @ErfanHossainShoaib 4 місяці тому

    why use external lib for this
    public record Pair(X left, Y right){
    public static Pair of(X x,Y y){
    return new Pair(x,y);
    }
    }

  • @ornelfranck
    @ornelfranck 4 місяці тому

    Nice

  • @mohanlal8692
    @mohanlal8692 4 місяці тому +2

    It's a nice tutorial and great explanation. But instead of using this libraries we can achieve this using Generics by creating our own DTOs. just my thoughts....

    • @Javatechie
      @Javatechie  4 місяці тому

      Yes we can create custom pojo but when library itself giving an easy option then why can't we choose that 😄

  • @rogerdinhelm4671
    @rogerdinhelm4671 4 місяці тому

    I think y-glide is something that American comedians would add, imitating russian mobsters. Russians are more likely to just pronounce "ee" sound harder.

  • @MsPrettyg00d
    @MsPrettyg00d 4 місяці тому +1

  • @theritesh973
    @theritesh973 4 місяці тому

    ❤❤❤

  • @saidineshbobbadhi8384
    @saidineshbobbadhi8384 4 місяці тому

    Our wallpapers are same

  • @luisdanielmesa
    @luisdanielmesa 4 місяці тому +3

    Bad idea... return a record instead, or fix your design flaws. Or create a sealed interface and allow only the types you need. I have worked for Novell, IBM, Amazon and I'm currently at Oracle... don't do this unless you want to suffer trying to figure out what type you're returning.

    • @Javatechie
      @Javatechie  4 місяці тому +2

      Why what complexity did you find In this approach. Just a simple example brother you have multiple upi payment method which one are you using? Just asking to help your question

    • @pardeepsaini3844
      @pardeepsaini3844 4 місяці тому +1

      🎉🎉🎉Yes Great Explanation.....

  • @sgr7ss
    @sgr7ss 3 місяці тому

    But it will create a tight coupling
    Not good for communication in Microservices!

  • @rishiraj2548
    @rishiraj2548 4 місяці тому

    🙂🙏🏻

  • @bhasoor
    @bhasoor 4 місяці тому

    Some obsessive moron wants to give name to list....pair is logically a simple list with limitation on size...
    These methods are not for developers who are born and bought up in java....
    These methods are specifically for people shifting to java from, i dont know which language...
    Honestly....These should not be part of standard java interview....if some interviewer asks this in interview.... understand that he is satisfying his ego...

  • @foddiebyage9696
    @foddiebyage9696 4 місяці тому +1

    You have a great experience knowledge but lack of continuity in uploading leads to less reach

    • @Javatechie
      @Javatechie  4 місяці тому

      Not getting you brother.

  • @gauravsrivastava17
    @gauravsrivastava17 4 дні тому +1

    Great

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

    Thank you