Viktar Patotski Profile picture
Dec 6 โ€ข 8 tweets โ€ข 2 min read
We moved our projects from #Java 11 to #Java 17 almost right after the LTS release. Here is a list of the Top 5 features that I have used and enjoyed for more than a year that may convince you to upgrade your projects. ๐Ÿงต๐Ÿ‘‡
`
record Point(int x, int y) {}
`

- this all you need to create POJO. No, constructors, getters, setters, etc. Just removed verbosity, which was disliked and criticized by many community members. ๐Ÿ““
Text blocks:
`String text = """
Long
formated
text.
""";
`
My SQL queries and JSON blocks in tests don't look like graveyards with all those `+.` โž•โŒ
Switch exceptions:
`
boolean isWeekend = switch (day) {
case SATURDAY, SUNDAY -> true;
default -> throw IllegalStateException("I's not weekend.");
};
`
More readable and less error-prone, and you won't forget to write a `break` at the end of the block. ๐Ÿ’ผ
Pattern Matching for instanceof:
`if (x instanceOf String s) {
int length = s.length();
}
`

No more (casting) inside the block. The code is less messy.๐Ÿšฏ
Helpful NullPointerExceptions:
`
person.wife.name = "Lidia";
`
throws:
Cannot assign field "name" because "person.wife" is null
java.lang.NPE: Cannot assign field "name" because "person.wife" is null

Finally, NPE describes exactly which variable was null.๐Ÿฅณ
Sealed classes:
`
public abstract sealed class Event
permits Start, Launch, Stop {}
`
If you ever wanted more power over who is allowed to extend your classes.๐Ÿ›‚
That's it. Thanks for reading.
If you are convinced to migrate to #Java 17 now, then like, retweet, and follow me for more content like this.
Happy Upgrade!๐Ÿ†™

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Viktar Patotski

Viktar Patotski Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @xpvit

Nov 29
Top 6 #Java testing libraries every Java developer should know about and use ๐Ÿ‘‡
JUnit 5 - unit testing framework for the Java programming language.

junit.org/junit5/
AssertJ by @JoCosti - fluent chaining assertions java library. One of the most powerful and convenient ways to write assertions. It's also included in the @springboot test framework.

assertj.github.io/doc/
Read 12 tweets
Jun 30, 2020
Often Software Developers are also called Professional Googlers. This means that we need to be really proficient in it. So this thread will provide you with tips and tricks which help you to become #10xengineer in Googling. Let's start โžก๏ธโžก๏ธโžก๏ธ
1. Use quotes for "exact match" searches. Often when you search for a particular error message try searching with quotes first to get your results faster. Very helpful when you need to understand error or warning messages in logs.
2. Use '*' in as a wildcard. Use case: when searching for errors messages replace parts specific to your code(folder or package names). Also helpful you want to find a song, but remember only some words then replace the unknown part with '*'. ๐ŸŽถ
Read 19 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(