Records Patterns, Performance and Serialization - JEP Café #8
Vložit
- čas přidán 1. 08. 2024
- This #JEPCafe discusses JEP 395: Records, released with JDK 16. We start with a short recap on what records are, then discuss the performances of the hash code computation with the `hashCode()` method, and the comparison of records using the `equals()` method. The performances are compared with the data objects offered by Kotlin and Lombok. We also cover record serialization and discuss patterns to serialize your legacy objects using records serialization (and get the security benefits of records serialization!).
⎯⎯⎯⎯⎯⎯ Chapters ⎯⎯⎯⎯⎯⎯
0:00 Intro
0:53 Carrying immutable state with records
1:32 Writing a record with components
2:47 Using constructors and accessors
5:34 Examining the bytecode of the `equals()`, `hashCode()`, and `toString()` implementations
7:12 Comparing the performances of `hashCode()` with Kotlin and Lombok
8:02 Comparing the performances of `equals()` with Kotlin and Lombok
10:20 Using Records as data transport objects
11:47 Using `writeReplace()` to serialize records
13:28 Using `readResolve()` to safely deserialize legacy objects
15:04 Outro
⎯⎯⎯⎯⎯⎯ Resources ⎯⎯⎯⎯⎯⎯
◦ Dev.java ➱ dev.java/
◦ How to use JMH ➱ openjdk.java.net/projects/cod...
◦ JEP 395: Records ➱ openjdk.java.net/jeps/395
◦ The @Serial annotation ➱ docs.oracle.com/en/java/javas...
◦ JDK 17 ➱ openjdk.java.net/projects/jdk17
◦ OpenJDK ➱ openjdk.java.net/
◦ Oracle Java ➱ www.oracle.com/java/
Categories: #Java #OpenJDK #JDK #JDK17 #Record #Serialization - Věda a technologie
This is the very concise and easy-to-understandable explanation I've ever watched about Java Record.
Hi Jose, please make a playlist on design patterns , design principles and how they are implemented in JDK. It would be really helpful for all of us. (in English) :)
I’m really fan of records, pretty easy to work with them, excellent content, cheers ☕️
Thanks, glad you liked it!
I am curios of using records for my DTOs but they have no setters. How do I handle my populator now if there are some fields I don't want to populate or are empty from the database?
I like the format of this video!
Thank you Jose!! Always delightful to learn from you!!
as always very useful and practical information. thank you
This was fantastic overview. Thanks a lot for the wonderful explanation.
Excellent talk as always. Thanks Jose 🤗
Glad you enjoyed it!
Thanks!
@@JosePaumard Hi Jose, please make a playlist on design patterns , design principles and how they are implemented in JDK. It would be really helpful for all of us. (in English) :)
Excellent video, thank you so much for making and sharing this, @José Paumard
Glad you enjoyed it!
What happpened to the section "Using records as data transfer objects"? It shows on the player bar regions, but it talks about serialization
wow thia was the first time i saw a presentation time and content planned with sips of coffee , but its java so possible
Great video again, I love both JEP Cafe and Inside Java Newscast. By the way, where can we find those glass coffee cups for sale? I would definitely buy one.
Me 2
Звук бы погромче. В остальном - отлично!
The sound should be a little louder. The rest is excellent!
0:42 why are Scala's case classes not mentioned? Scala has been around for longer than Kotlin.
good question
Just one, but the most important question.... Where the hell i buy this awesome mug?!!
Your videos are excellent!
Which earlier JEP Café talks about records? I like this video, but cannot find the earlier one.
We have a Playlist for that 😉
czcams.com/play/PLX8CzqL3ArzV4BpOzLanxd4bZr46x5e87.html
@@java Thank you. I see the first JEP 395 : Records discussion is a topic at the end of the first JEP Café #1.
I'm happy the use case for Lombok is going away. Lombok was never problem free.
old-fashioned
In the code at 4:48, the compareTo method needs to be replaced with
@Override
public int compareTo(Population other) {
return Integer.compare(this.number, other.number);
}