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.
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.
*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
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
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.
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.
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.
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
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....
I think y-glide is something that American comedians would add, imitating russian mobsters. Russians are more likely to just pronounce "ee" sound harder.
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.
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
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...
We used to create our own pair classes to use in project. Now it's cool to have ready to use libs. Thank Techie
I have implemented this concept in one of our existing methods after watching your video. You are awesome!
Appreciate your efforts Basant! God Bless you!🙏👍
Thanks buddy. Every time i got a notification from you , got curious to learn new thing to build my carrier growth.
Return a list of POJOs. Another way to implement this. Like in all languages, different ways to perform such tasks.
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?
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.
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.
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.
*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
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
Why not just return a record?
what if you need to return multiple records?
@@inzi27 put your records into a single record. and return this single record.
Can you explain with code
Same question.
Nested records pattern is supported from java 21
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.
Please drop an email to javatechie4u@gmail.com and elaborate your usecase little bit
Awesome contents....
Kotlin has this feature and I find it awesome.
Interesting Video. Thanks for sharing Basant.
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.
Thanks sir to share this knowledge 🙏, even though i used Pair class many times in my code.
This common lang3 will reduce writing multiple methods, thanks for the info ❤
This was awesome Basant..thank you for the learnings
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.
thanks as always very resourceful
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
Okay noted Sritam ✅️.
Can use RECORD !?
@java techie please make a playlist on java 9,11
features
nice information, I created custom pair class in my project, we will use this feature next onwards in my project
Thanks.. it is very useful for developers ❤👍
We can use pojo class instead, which would be more cleaner and easy to understand approach, this approach creates confusion for new devs
Wow.... 🎉🎉🎉🎉🎉
Useful concept
Nice feature.
Thank You Sir ❤❤
Thank you
Thank you it's helpful ❤
Great
Great to know
Why we need this when we have hashmap? @Javatechie
Can we return more than 3 different objects..
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);
}
}
Nice
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....
Yes we can create custom pojo but when library itself giving an easy option then why can't we choose that 😄
I think y-glide is something that American comedians would add, imitating russian mobsters. Russians are more likely to just pronounce "ee" sound harder.
❤
❤❤❤
Our wallpapers are same
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.
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
🎉🎉🎉Yes Great Explanation.....
But it will create a tight coupling
Not good for communication in Microservices!
🙂🙏🏻
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...
You have a great experience knowledge but lack of continuity in uploading leads to less reach
Not getting you brother.
Great
Thank you