Since the previous LTS, JDK 17, was released in 2021, there are quite lots of features added into the Java specification. In this year, the latest JDK 21 LTS version is released and brings us many formal functions to improve our daily works. This session will focus on the new features, including String Templates, Sequenced Collections, Record Patterns, Pattern Matching for switch, Unnamed features and Virtual Threads.
Testing with JUnit 5 and Spring - Spring I/O 2022Sam Brannen
This session will give you an overview of the latest and greatest in the world of testing using JUnit Jupiter (a.k.a. JUnit 5) and the Spring Framework.
The focus will be major new features in JUnit Jupiter 5.8 and 5.9 as well as recent and upcoming enhancements to Spring's integration testing support.
Slides for meetup @Talentica Software on 25th January 2020
Topics Covered:
1. Dependency Injection
2. Ng-schematics
3. How to structure your apps
4. Deployment
A presentation I gave in Expert Days 2012. In this presentations I explain how most of the features in the C# language work, including Iterators, Lambdas, Linq, Dynamics, and more.
We like the architecture of our applications to revolve around the business logic, not around technical details (and especially not around the database).
In my team at Sky Network Services we use the Clean Architecture and it has given us a great deal of benefits: the business logic is explicit, we are free to change our technical decisions, the app is easy to test, working on it is faster and scalable, it’s hard to do the wrong thing, and many more.
But it comes at a cost, of course. In this talk I’ll tell you the story of our experience with Clean Architecture and give you some tips to get the most out of it.
Example Project
https://github.com/mattia-battiston/clean-architecture-example
Downloads
Online: https://goo.gl/DTxftJ
PDF: https://goo.gl/ZAtdBN
Powerpoint: https://goo.gl/D54wdZ (but you need to install these fonts to see it properly: https://goo.gl/iH8SO5)
SOLID Design Principles applied in JavaIonut Bilica
Video: https://www.youtube.com/watch?v=0cU-4LrcWI0
SOLID Design Principles applied in Java: rules to develop scalable and easily maintainable code
Speaker: Ionut Bilica - Senior Software Developer @ Luxoft Romania.
During this talk we will discuss about the SOLID Principles described by Robert C. Martin, applying them in the Java programming language. Each principle will be explained in detail, with practical Java examples.
We will asses how these principles make it easy to develop the software for the entire duration of the project, and how some problems can appear if these principles are not applied. We will present common code fragments that do not respect these principles, and we'll see how we can correct them. Taking the SOLID principles into consideration, we will also analyse a real Java project using a Static Code Analyzer tool (e.g. STAN).
Finally, we will discuss the strategies on how to apply these design principles in "greenfield" projects, as well as "legacy" projects, while offering some tips and tricks.
Testing with JUnit 5 and Spring - Spring I/O 2022Sam Brannen
This session will give you an overview of the latest and greatest in the world of testing using JUnit Jupiter (a.k.a. JUnit 5) and the Spring Framework.
The focus will be major new features in JUnit Jupiter 5.8 and 5.9 as well as recent and upcoming enhancements to Spring's integration testing support.
Slides for meetup @Talentica Software on 25th January 2020
Topics Covered:
1. Dependency Injection
2. Ng-schematics
3. How to structure your apps
4. Deployment
A presentation I gave in Expert Days 2012. In this presentations I explain how most of the features in the C# language work, including Iterators, Lambdas, Linq, Dynamics, and more.
We like the architecture of our applications to revolve around the business logic, not around technical details (and especially not around the database).
In my team at Sky Network Services we use the Clean Architecture and it has given us a great deal of benefits: the business logic is explicit, we are free to change our technical decisions, the app is easy to test, working on it is faster and scalable, it’s hard to do the wrong thing, and many more.
But it comes at a cost, of course. In this talk I’ll tell you the story of our experience with Clean Architecture and give you some tips to get the most out of it.
Example Project
https://github.com/mattia-battiston/clean-architecture-example
Downloads
Online: https://goo.gl/DTxftJ
PDF: https://goo.gl/ZAtdBN
Powerpoint: https://goo.gl/D54wdZ (but you need to install these fonts to see it properly: https://goo.gl/iH8SO5)
SOLID Design Principles applied in JavaIonut Bilica
Video: https://www.youtube.com/watch?v=0cU-4LrcWI0
SOLID Design Principles applied in Java: rules to develop scalable and easily maintainable code
Speaker: Ionut Bilica - Senior Software Developer @ Luxoft Romania.
During this talk we will discuss about the SOLID Principles described by Robert C. Martin, applying them in the Java programming language. Each principle will be explained in detail, with practical Java examples.
We will asses how these principles make it easy to develop the software for the entire duration of the project, and how some problems can appear if these principles are not applied. We will present common code fragments that do not respect these principles, and we'll see how we can correct them. Taking the SOLID principles into consideration, we will also analyse a real Java project using a Static Code Analyzer tool (e.g. STAN).
Finally, we will discuss the strategies on how to apply these design principles in "greenfield" projects, as well as "legacy" projects, while offering some tips and tricks.
Presented at Jazoon, April 28th, 2017
A revolution is about to begin. WebAssembly (aka wasm) is shipping in all modern browsers, but since it’s (intentionally) very low level, it can be difficult to understand how it will be critical to future web applications–and definitely not just games and C++!
In this talk, Jay will demystify stack assembly languages like WebAssembly, even if you have zero experience with assembly and linear memory.
Cypress-vs-Playwright: Let the Code SpeakApplitools
Hear what the code has to say in this epic matchup between test automation frameworks—Cypress vs. Playwright—and see who will be crowned the winner in this webinar by Applitools
See the session materials at https://applitools.info/pmv
Rather than compile lists of feature comparisons, this matchup is a battle of the code where Cypress Ambassador Filip Hric and Automation Panda Andrew Knight implement small coding challenges in JavaScript using Cypress and Playwright, respectively. They then compare and contrast their solutions, and the audience chooses the winner.
See comparisons of Cypress and Playwright in:
API requests
Inline frames
Alerts
Page Objects...and more!
From the audience:
"This was great. Loved the playful banter."
"Event was really well done..fair play to all involved"
"Very Useful and Interesting Session"
A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017Carlos Buenosvinos
Event-based architectures such as Event Sourcing provide multiple benefits: scalability, complexity management, auditing, etc. However, let’s face it, getting there is quite hard. We lack skills, expertise and courage.
In this talk, I’m going to show you some tips and tricks to painless evolve your current architecture towards Event Sourcing, one small step at a time. We’ll start from an Hexagonal Architecture application and we’ll end up in the Event Sourcing doors. The path that we’ll follow is:
Hexagonal Architecture
Hexagonal Architecture with Domain Events
Stepping Stone Architecture (CQRS without Event Sourcing)
Event Sourcing
Talk level: Intermediate to Expert
Requirements: Basic concepts of Hexagonal Architecture (Entities, Repositories, Application Services, etc.)
SOLID Principles and The Clean ArchitectureMohamed Galal
This presentation is held at @blablaconnect Cairo office, Monday 31 December 2018.
In this presentation we will discuss the following topics:
- SOLID principles.
- Design Pattern vs. Clean Architecture.
- Successful software architecture characteristics.
- The Clean Architecture.
- Real life example.
Java 8 is coming soon. In this presentation I have outlined the major Java 8 features. You get information about interface improvements, functional interfaces, method references, lambdas, java.util.function, java.util.stream
Introducing Playwright's New Test RunnerApplitools
Playwright Test is a new test runner built from scratch by the Playwright team specifically to accommodate end-to-end testing needs. Join Principal Engineer, Andrey Lushinkov as he demonstrates how to use Playwright Test to author new tests, how to migrate existing tests, how to deploy them on CI, and debug them if something goes wrong.
These are the slides of my "Fake it Outside-In TDD" session at the #XP2017 conference. Do not miss to check out the referenced screencasts that illustrate the approach very well: https://www.youtube.com/playlist?list=PL_ueet93U84VIy8O7U4dUV0GyGvuzFAt8
Presented at Jazoon, April 28th, 2017
A revolution is about to begin. WebAssembly (aka wasm) is shipping in all modern browsers, but since it’s (intentionally) very low level, it can be difficult to understand how it will be critical to future web applications–and definitely not just games and C++!
In this talk, Jay will demystify stack assembly languages like WebAssembly, even if you have zero experience with assembly and linear memory.
Cypress-vs-Playwright: Let the Code SpeakApplitools
Hear what the code has to say in this epic matchup between test automation frameworks—Cypress vs. Playwright—and see who will be crowned the winner in this webinar by Applitools
See the session materials at https://applitools.info/pmv
Rather than compile lists of feature comparisons, this matchup is a battle of the code where Cypress Ambassador Filip Hric and Automation Panda Andrew Knight implement small coding challenges in JavaScript using Cypress and Playwright, respectively. They then compare and contrast their solutions, and the audience chooses the winner.
See comparisons of Cypress and Playwright in:
API requests
Inline frames
Alerts
Page Objects...and more!
From the audience:
"This was great. Loved the playful banter."
"Event was really well done..fair play to all involved"
"Very Useful and Interesting Session"
A Journey from Hexagonal Architecture to Event Sourcing - SymfonyCon Cluj 2017Carlos Buenosvinos
Event-based architectures such as Event Sourcing provide multiple benefits: scalability, complexity management, auditing, etc. However, let’s face it, getting there is quite hard. We lack skills, expertise and courage.
In this talk, I’m going to show you some tips and tricks to painless evolve your current architecture towards Event Sourcing, one small step at a time. We’ll start from an Hexagonal Architecture application and we’ll end up in the Event Sourcing doors. The path that we’ll follow is:
Hexagonal Architecture
Hexagonal Architecture with Domain Events
Stepping Stone Architecture (CQRS without Event Sourcing)
Event Sourcing
Talk level: Intermediate to Expert
Requirements: Basic concepts of Hexagonal Architecture (Entities, Repositories, Application Services, etc.)
SOLID Principles and The Clean ArchitectureMohamed Galal
This presentation is held at @blablaconnect Cairo office, Monday 31 December 2018.
In this presentation we will discuss the following topics:
- SOLID principles.
- Design Pattern vs. Clean Architecture.
- Successful software architecture characteristics.
- The Clean Architecture.
- Real life example.
Java 8 is coming soon. In this presentation I have outlined the major Java 8 features. You get information about interface improvements, functional interfaces, method references, lambdas, java.util.function, java.util.stream
Introducing Playwright's New Test RunnerApplitools
Playwright Test is a new test runner built from scratch by the Playwright team specifically to accommodate end-to-end testing needs. Join Principal Engineer, Andrey Lushinkov as he demonstrates how to use Playwright Test to author new tests, how to migrate existing tests, how to deploy them on CI, and debug them if something goes wrong.
These are the slides of my "Fake it Outside-In TDD" session at the #XP2017 conference. Do not miss to check out the referenced screencasts that illustrate the approach very well: https://www.youtube.com/playlist?list=PL_ueet93U84VIy8O7U4dUV0GyGvuzFAt8
JCConf 2022 - New Features in Java 18 & 19Joseph Kuo
Java 18 and 19 are released in 2022, including Simple Web Server, Code Snippet in JavaDoc, Vector API, Foreign Function & Memory API, Pattern Matching for switch, Record Patterns and Virtual Threads. Although some of them are still in the preview or incubator stage, we still need to keep learning about the knowledge. They not only improve performance of Java applications, but also introduce new syntax and API to ease our effort to write more readable and efficient code. This session is to introduce these new features and their intentions.
https://cyberjos.blog/java/seminar/jcconf-2022-new-features-in-java-18-19/
After 3 years, the third LTS version, Java 17, was released in September 2021. We all are very excited and keen to learn more about new changes it brings to us. However, many projects and products are still using Java 11, or even Java 8. In this session, we will not only focus on those amazing features, but also have a quick introduction on why we should migrate to Java 17 and how.
https://cyberjos.blog/java/seminar/jcconf-2021-java17-the-next-lts/
JCConf 2020 - New Java Features Released in 2020Joseph Kuo
In 2020, Java 14 and 15 are released with many great features, including ZGC, Shenandoah GC, helpful NullPointerExceptions, pattern matching for instanceof, switch expressions, text blocks, records, hidden classes, and sealed classes. They not only improve performance of GC and Java applications, but also introduce new syntax to ease our effort to write more readable and efficient code. Let's take a look at those features!
https://cyberjos.blog/java/seminar/jcconf-2020-new-java-features-released-in-2020/
TWJUG x Oracle Groundbreakers 2019 Taiwan - What’s New in Last Java VersionsJoseph Kuo
We all know that Java's release cycle now is 6 months. The Java 12 has been released in March 2019, with the next version, Java 13, to come in September 2019. This session is to introduce new features and functions in Java 12 and 13. Also, we will mention other relevant features released in the previous Java versions.
https://cyberjos.blog/java/seminar/oracle-groundbreakers-2019-taiwan-whats-new-in-last-java-versions/
JCConf 2018 - Retrospect and Prospect of JavaJoseph Kuo
It has been more than 2 decades since the first version of Java was released in 1996. As of today, Java has been applied in many different fields form large-scale distributed computing services with scalability and stability, to millions of various APPs installed in mobile devices/cellphones/cars all over the world. At this time when Java 11 is being ready to introduce more new enhancements and deprecate legacy libraries, let us retrospect the past history of Java from the beginning, focus on recent significant changes from Java 8 to 10, prospect new features included in Java 11, and speculate what functionalities may come out in the future.
https://cyberjos.blog/java/seminar/jcconf-2018-retrospect-and-prospect-of-java/
JCConf 2017 - Next Generation of Cloud Computing: Edge Computing and Apache E...Joseph Kuo
Cloud computing has been developed more than one decade and still keeps growing and growing. At the present time when we enjoy the huge benefits it brings to us, we are also aware of its deficiency that we have to enhance, especially for applications running against IoT. This session is to present the next generation of cloud computing: Edge Computing. We will introduce you what Edge Computing is, why we need it, and how it works with current cloud computing services. Furthermore, when we get involved into edge computing, we need a tool to help us to analysis real-time and continuous data streams generated by devices, equipment and systems on IoT. Therefore we will also present Apache Edgent, a programming model and micro-kernel style run-time, and show you how it works in conjunction with centralized analytic systems and provides efficient and timely analytic across the whole IoT ecosystem.
https://cyberjos.blog/java/seminar/jcconf-2017-next-generation-of-cloud-computing-edge-computing-and-apache-edgent/
JCConf 2016 - Cloud Computing Applications - Hazelcast, Spark and IgniteJoseph Kuo
This session aims to establish applications running against distributed and scalable system, or as we know cloud computing system. We will introduce you not only briefing of Hazelcast but also deeper kernel of it, and how it works with Spark, the most famous Map-reduce library. Furthermore, we will introduce another in-memory cache called Apache Ignite and compare it with Hazelcast to see what's the difference between them. In the end, we will give a demonstration showing how Hazelcast and Spark work together well to form a cloud-base service which is distributed, flexible, reliable, available, scalable and stable. You can find demo code here: https://github.com/CyberJos/jcconf2016-hazelcast-spark
https://cyberjos.blog/java/seminar/jcconf-2016-cloud-computing-applications-hazelcast-spark-and-ignite/
Establish The Core of Cloud Computing Application by Using Hazelcast (Chinese)Joseph Kuo
The concept of cloud computing has been introduced for several years. Many of us may be able to roughly imagine what it is, some of us may know how to describe it, but only a few do know how to implement it. Does NoSQL, MapReduce or Big Data equal to cloud computing? Can a service be said that it is cloud-based if it is using any of those tools? Many companies and groups have declared that their online services are cloud-based or they are using cloud computing, but are those all true? Except for the questions above, where should we start if we would like to establish a cloud-based service which is distributed, flexible, reliable, available, scalable and stable? This session intends to lead you through the gate of mysteries and head to the beautiful realm of cloud computing by using powerful tools, like Hazelcast. Welcome to journey with us to the core of cloud computing application!
https://cyberjos.blog/java/seminar/jcconf-2014-establish-the-core-of-cloud-computing-application-by-using-hazelcast/
6. 2023 State of Java Ecosystem
• New Relic first published in March 2020
• 2023 state was published in April 2023
• Based on data gathered from millions of
applications providing performance data
• The data for this report was drawn entirely
from applications reporting to New Relic in
January 2023 and does not provide a global
picture of Java usage.
6
Source: https://newrelic.com/resources/report/2023-state-of-java-ecosystem
16. Pattern Matching for switch
String text = switch (obj) {
case null -> "NULL"; // null check
case String s -> "String: " + s;
case Integer i
when i < 10_000 -> "Small Int: " + i;
case Integer i -> "Big Int: " + i;
case Long l -> "Long: " + l;
case Number n -> "Number: " + n;
default -> "Object: " + obj;
}
16
1. 可以檢查 null
2. 可以用 when 來增加判斷式
(guarded pattern)
3. Java14 讓 switch 可以回
傳值並設定 text 變數內容
17. 注意!上下順序很重要!
String text = switch (obj) {
case null -> "NULL";
case String s -> "String: " + s;
case Number n -> "Number: " + n;
// Error: this case label is dominated
// by a preceding case label
case Integer i -> "Integer: " + i; // unreachable
case Long l -> "Long: " + l;
default -> "Object: " + obj;
}
17
到不了的地方叫遠方
18. 支配權 Dominance
• 父類別大於子類別 (例:Number > Integer)
• Unguarded pattern 大於 guarded pattern
(case Type > case Type when expr.)
• Guarded pattern when true 大於其他
pattern(guarded & unguarded)
• Pattern 大於常數(Integer i > 1, 2)
• Enum 類別大於常數(Color > Color.RED)
• when 不會進行過多的額外檢查
18
19. 建議撰寫原則
• 先寫 case null (純粹為了易讀性與維護性)
• 次寫 case 常數和列舉常數
• 再寫 guarded 的 case Type t when 判斷式
• 後寫 unguarded 的 case Type t
• 特別注意 Type 的子類別要放在父類別之前
• 最後寫 default 做收尾(若未窮舉的話)
19
20. 搭配 enum 一起用
enum Color { RED, GREEN, BLUE, YELLOW, PURPLE }
String text = switch (obj) {
case null -> "NULL";
case Color.BLUE -> "Color.BLUE"; // 短版本
case Color c
when c == Color.RED -> "Color.RED";// 與上式等價
case Color c -> "Color: others"; // 注意支配性
case int[] ia -> "Int array: " + ia; // 陣列也可以
default -> "Object: " + obj;
}
20
記得 enum、sealed 需要注
意是否要窮舉所有可能值!
22. class Point { // immutable
private final int x, y;
public Point(int x, int y) { this.x=x; this.y=y; }
public int x() { return x; }
public int y() { return y; }
public boolean equals(Object o) {
return o instanceof Point
&& ((Point) o).x == x
&& ((Point) o).y == y;
}
public int hashCode() { return Objects.hash(x, y); }
public String toString() {
return String.format("Point[x=%d, y=%d]", x, y);
}
}
回到 Java 上古時代(= Java 7)
22
23. Java16 record + Java17 sealed
23
record Point(int x, int y) {} // 上頁的程式碼濃縮成一行了
// 順便增加一些複雜度
sealed interface Shape
permits Circle, Rectangle, Triangle {
public static void check(Point p) {
if (p.x() <= 0)
throw new IllegalArgumentException("NG!");
}
}
record Circle(Point p, int r, Color c)
implements Shape {}
record Rectangle(Point p1, Point p2, Color c)
implements Shape {}
record Triangle(Point p1, Point p2, Point p3, Color c)
implements Shape {}
24. return switch (obj) {
case null -> "NULL";
case Point p -> "Point: " + p; // Pattern matching
case Circle(Point p, int r, Color c) // record pattern
-> "Circle: p:" + p;
case Rectangle(Point p1, Point p2, Color c)
-> "Rectangle: 1:" + p1 + ", 2:" + p2;
case Triangle(Point p1, Point p2, Point p3, Color c)
-> "Triangle: 1:" + p1 + ", 2:" + p2 + ", 3:" + p3;
default -> "Object: " + obj;
};
24
這樣一來就不需要使用
case Circle c -> c.p();
Record Pattern
25. record Pair<T>(T a, T b) {}
private Pair<Shape> o;
switch (o) {
// 要窮舉所有可能值
case Pair<Shape>(Circle c, Shape s) -> ...
case Pair<Shape>(Rectangle r, Circle c) -> ...
case Pair<Shape>(Rectangle r, Rectangle r) -> ...
case Pair<Shape>(Rectangle r, Triangle t) -> ...
case Pair<Shape>(Triangle t, Shape s) -> ...
// 或是用下列任一行收尾
case Pair<Shape>(var a, var b) -> ...
case Pair<Shape> x -> ...
default -> ...
}
25
要注意是否已窮舉
26. If record in if
// Java 16 ~ 20
if (o instanceof Point p) {
int x = p.x();
int y = p.y();
System.out.println(x + y);
}
// Java 21 Record pattern
if (o instanceof Point(int x, int y)) {
System.out.println(x + y);
}
26
27. 更複雜的 Record Pattern
if (o instanceof Circle(Point(int x, int y), int r, Color c)) {
System.out.println(x + y);
}
if (o instanceof Rectangle(Point(var x,var y), var p2, var c)) {
System.out.println(x); // 也可以使用 var
}
if (o instanceof Triangle(Point(int x1, int y1),
Point(var x2, var y2), Point p3, var c)) {
System.out.println(c);
}
27
程式碼能夠
簡化嗎?
28. Unnamed Patterns (Preview)
if (o instanceof Circle(Point(int x, int y), int _, Color _) {
System.out.println(x + y); // unnamed pattern variable
}
if (o instanceof Rectangle(Point(var x, _), _, _) {
System.out.println(x); // unnamed pattern (Type v)
}
if (o instanceof Triangle(_, _, _, var c) { // unnamed pattern
System.out.println(c);
}
if (o instanceof Point _) { // unnamed pattern variable
System.out.println("Point!");
}
28
程式碼複雜度降
低,可讀性增加!
29. Unnamed Variables (Preview)
var points = new ArrayList<Point>(List.of(p1, p2, p3, p4, p5));
for (Point _ : points) { // enhanced for loop
if (DEBUG) count++;
}
for (int i = 0, _ = init(); i < count; i++) { // for statement
try (var _ = getRes()) { // try-with-resources statement
Point p = points.getFirst();
Shape.check(p);
m.putAll(Arrays.stream(Color.values())
.map(c -> new Circle(p, i, c))
.collect(toMap(Function.identity(),
_ -> 1L)) //lambda
);
} catch (IllegalArgumentException _) { // exception
var _ = points.removeFirst(); // local variable
}
}
29
30. 這是禁止事項 🙅
• o instanceof _
• o instanceof _(int x, int y)
• o instanceof var _
• case _
• case var _
• case Type(_)
• void test(String x, int _) {}
• ...
30
32. 各自表述,沒有共識
First element Last element
List list.get(0) list.get(list.size() - 1)
Deque deque.getFirst() deque.getLast()
SortedSet set.first() set.last()
LinkedHashSet set.iterator().next() // missing
32
不同集合取得
首尾元素有不
同做法……
35. SequencedCollection
// new method
SequencedCollection<E> reversed();
// methods promoted from Deque
void addFirst(E);
void addLast(E);
E getFirst();
E getLast();
E removeFirst();
E removeLast();
// add*(E) & remove*() are optional (unmodifiable)
// get*() & remove*() throw NoSuchElementEx if empty
35
50. Core Java Library
• JEP 431: Sequenced Collections
• JEP 442: Foreign Function & Memory API
(Third Preview)
• JEP 444: Virtual Threads
• JEP 446: Scoped Values (Preview)
• JEP 448: Vector API (Sixth Incubator)
• JEP 453: Structured Concurrency (Preview)
50
51. Java Language Specification
• JEP 430: String Templates (Preview)
• JEP 440: Record Patterns
• JEP 441: Pattern Matching for switch
• JEP 443: Unnamed Patterns and Variables
(Preview)
• JEP 445: Unnamed Classes and Instance
Main Methods (Preview)
51
52. HotSpot & Security
• JEP 439: Generational ZGC
• JEP 449: Deprecate the Windows 32-bit x86
Port for Removal
• JEP 451: Prepare to Disallow the Dynamic
Loading of Agents
• JEP 452: Key Encapsulation Mechanism API
• NOTE THAT JEP 404, Generational
Shenandoah (Experimental), originally
targeted for 21, was officially removed
52