Clean Code with Records, Sealed Classes and Pattern Matching by José Paumard

  Рет қаралды 25,868

Devoxx

Devoxx

Күн бұрын

Пікірлер: 21
@AyushmanAdhikary
@AyushmanAdhikary 4 ай бұрын
Very informative. Always enjoy your content which is conceptually so clear to understand.
@EmmanuelBLONVIA
@EmmanuelBLONVIA 3 ай бұрын
13:38 Introducing a security breach in java solved by records 14:03 When you deserialize an object, no constructor is called 😳 14:30 here's how using record instead of class protect your code from what can be called "deserialization injection" 😌 19:35 Pattern matching 34:08 Using the record components in the pattern matching expression
@MrGabblit
@MrGabblit 2 жыл бұрын
Very insightful, well presented talk
@PietervandenHombergh
@PietervandenHombergh 2 жыл бұрын
Coverage in the switch can be achieved with an anon innner of the Shape in a unit test.
@francksgenlecroyant
@francksgenlecroyant Жыл бұрын
I think the serialization process is using the Constructor even with regular java classes, the reason why the validation rule is not triggered is because, the constructor which is involved here is the default non-args constructor. That's it!
@DavidBeaumont
@DavidBeaumont 2 жыл бұрын
I have a question about pattern matching on records (about 35:00). If you use "(Circle radius) -> radius * radius", what happens if you add a new component to Circle (e.g. a colour)? Now the record has a new canonical constructor. And worse, what if the property is the same type as the existing value (e.g. "double celcius"). Now I think that all the callers using pattern matching must update their code with a '_'? I guess (looking ahead) the owner of the type would be responsible for adding an explicit custom pattern to retain the old semantics, but this would be a manual thing you need to remember to do.
@TaranovskiAlex
@TaranovskiAlex 2 жыл бұрын
Thank you for the great talk!
@PanMaciek
@PanMaciek Жыл бұрын
I love using pattern matching, but seeing how java is going to implement this I'm not sure it will feel great
@GavinFreeborn
@GavinFreeborn Жыл бұрын
This summarizes every functional feature java has added. Kinda sad but I guess it's at least there. Unfortunately a poor implementation means it's much harder to sell at work
@khalled95
@khalled95 Жыл бұрын
The main issues in java 17 that companies don't use or upgrade to it, most companies stick with java 8 or 11
@jamesschmames6416
@jamesschmames6416 2 жыл бұрын
I thought it was bad form to throw exceptions in a constructor.
@patrickproctor3462
@patrickproctor3462 Жыл бұрын
It should be done judiciously. We use exception throws in constructors for user-provided data so we fail very loudly, very clearly, and in a way that tells our UI developers (and others) that they broke the rules of our API (without resorting to WSDLs which NO ONE wants to maintain).
@OMGitzBadCompany
@OMGitzBadCompany Жыл бұрын
It's far better than knowingly letting invalid objects pop into existence.
@IFraid
@IFraid 2 жыл бұрын
So, basically c#
@rsrini7
@rsrini7 Жыл бұрын
java becomes another scala
@pierre-jeanmartin5621
@pierre-jeanmartin5621 2 жыл бұрын
They should have picked a new language keyword instead of “instanceof”. Something like “ofpattern”. if ( object ofpattern Point(int x, int, y) ) // use x and y Or maybe it’s just me very not liking instanceof 😅
@DavidBeaumont
@DavidBeaumont 2 жыл бұрын
Adding new keywords is very hard since it's adding a new reserved word to the language specification and might make existing code stop compiling (e.g. if I have a variable or type called "ofpattern". I agree that "instanceof" is a bit unintuitive though, but it might be the pragmatic choice.
@pierre-jeanmartin5621
@pierre-jeanmartin5621 2 жыл бұрын
@@DavidBeaumont i understand but it’s not like all modern IDE have a Replace in Files feature. A simple name like record was introduced but a non camel case keyword like « ofpattern » would be a problem 🤨🤔
@DavidBeaumont
@DavidBeaumont 2 жыл бұрын
@@pierre-jeanmartin5621 what about tools which process Java files or databases containing symbol information of binaries for debugging. There are a lot of potential ways new keywords can mess things up in hard to fix ways. Record is, I think, much easier because it's a new type identifier rather than a language keyword.
@MrKar18
@MrKar18 Жыл бұрын
​@@pierre-jeanmartin5621what about 10000 if libraries using? You can't modify existing libraries. Java has always been backward compatible. It can't be make or break as its enterprise's go to language.
@KangoV
@KangoV 9 ай бұрын
maybe if(object match Point(var x, var y)); ?
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 51 МЛН
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 17 МЛН
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 4,3 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 16 МЛН
A 1.5MB Java Container App? Yes you can! by Shaun Smith
32:53
Revisiting Design Patterns after 20 by Edson Yanaga
48:24
LLC 2024 - Lightning talks - Ultimate memory tagging and Zoned XFS
41:31
Lund Linux Conference
Рет қаралды 40
2022: A GitOps Odyssey by Robin De Roeck
50:35
Devoxx
Рет қаралды 733
Java *is* agile by Venkat Subramaniam
46:35
Devoxx
Рет қаралды 23 М.
The Amazing Features of Modern Java  - Venkat Subramaniam
1:02:01
Developer Summit
Рет қаралды 32 М.
Java Streams: Beyond The Basics
49:21
Jfokus
Рет қаралды 73 М.
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 51 МЛН