We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Sailing Modern Java by Piotr Przybyl
Explore modern Java best practices for improved code readability, maintainability, and concurrency control, including record patterns, virtual threads, and Java 19 and 20 features, as well as testing and debugging strategies.
- Don’t pin virtual threads, as it can lead to performance issues.
- Use record patterns and pattern matching for switch expressions to improve code readability and maintainability.
- Upgrade to the latest JDK version to take advantage of new features and improvements.
- Virtual threads are lightweight and can be created quickly, making them suitable for large-scale concurrent applications.
- Structured concurrency can help simplify concurrent programming and reduce the risk of bugs.
- Use test containers to simplify testing and improve code quality.
-
Consider using the
record
keyword to define immutable data classes. - Java 19 and 20 introduce new features such as pattern matching and switch expressions.
- Virtual threads are not suitable for use cases that require precise control over thread scheduling.
-
Use the
structured-task
scope to manage concurrent tasks and improve code readability. - Java Flight Recorder can be used to monitor and analyze application performance.
-
Consider using the
sealed
keyword to define sealed classes that cannot be extended. - Virtual threads can help improve application performance and scalability.