Heinz Kabutz: Java 8, 9 &10
It is the year 2018. Heinz Kabutz is teaching a Java patterns masterclass. As is his custom, he asks what version each student is using. As we go around the room, most are on Java 8. No one on Java 9 or 10. But two pour souls are still hacking Java 5. How can this be? In 2018? We never asked the reason, but most likely a library they depend on is holding them back.
With every Java version, we get shiny new features. These are not only there to be cool, but to make us more productive. When we ask programmers what version they are on, even today a lot are programming in Java 7. And those that are on Java 8 are often not taking advantage of the power that the new Java Streams API offers.
But that's not all. We are currently on Java 10, with Java 11 scheduled for September. The increments are shorter, with less features added per new version. There are many reasons to move code over to Java 10. In most cases, your projects should compile and run with few changes. Only if you have been naughty will the compiler complain. We do need to test every class, but that is true whenever we move to a new JVM release.
In this one-day workshop, we will refactor an largish e-commerce application. 370k LOC and 1200 classes. The first refactorings are to bring our code up to Java 7. We then spend the bulk of our time moving our collection manipulating code to Java 8 Streams. Finally we will refactor code to Java 9 and 10 to take advantage of the new features. This workshop is very hands-on, so please bring along your laptop with IntelliJ IDEA 2018.1.4 and JDK 10. For IDEA you can use either the Community or the Ultimate editions.
Your Instructor: Dr. Heinz M. Kabutz
Note that this curriculum is only a guide of the refactorings that we will do. It depends on the student as to how many he will be able to complete in the available time. Detailed walkthroughs will be available for most of the refactorings
1. Welcome To The Age Of Monolithic Legacy
1.2 Introduction to Refactoring and Unit Testing
1.3 Setting Up IntelliJ
1.4 Building the OFBiz Project
1.5 Analyzing Code for Refactoring in IDEA
2. Cleaning Up Some Pre-Java 5 Dinosaur Code
2.1 Refactoring to Java 5
2.2 Getting Rid of Unnecessary Boxing/Unboxing
2.3 Changing StringBuffer to StringBuilder
2.4 String.contains() instead of indexOf()
2.5 Replace 'for' Loop With Java 5 for-in
2.6 Replace 'while' Loop With Java 5 for-in
3. Moving to Java 7, Our Code is Entering the Age of Mammals
3.1 More Java 5 Refactorings
3.2 Java 7 Refactorings, Diamond Operator
3.3 Java 7 Collapsing try-catch Blocks
3.4 Java 7 Refactoring to try-with-resource
4. Fire is Discovered in Lambdas and Method References in Java 8
4.1 Java 8 Static Methods in Interfaces
4.2 Java 8 Default Methods in Interfaces
4.3 How Functional Interfaces Work
4.4 The Four Types of Method References
4.5 Refactoring to Iterable.forEach()
4.6 Refactoring to use Collection.removeIf()
5. Java 8 Streams, We Are Moving Towards the Stone Age
5.1 Introduction to Java 8 Streams
5.2 Stream map(), filter(), collect()
5.3 Refactoring to Lambdas and Method References
5.4 Comparators in Java 8
5.6 Single Map Methods getOrDefault(), merge(), putIfAbsent()
6. Refactoring Our Code to use map()/collect() in the Bronze Age
6.1 Refactoring ContainerConfig.
6.2 collect() in UtilCache.values()
6.3 map()/collect() in UtilDateTime.getTimeZones()
6.4 map()/collect() in EntityJoinOperator.freeze()
6.5 Collection.forEach() in EntityJoinOperator.visit()
6.6 map()/filter()/collect() in EntitytFinderUtil.
6.7 map()/filter()/collect() in EntityDataLoader.
6.8 map()/collect() in DelegatorContainer.start()
6.9 map()/sum() in OagisShipmentServices.
6.10 Arrays.setAll() in ShoppingListEvents.
7. Matching and Finding in Streams, Our Code is Nearing the Iron Age
7.1 Stream all/any/noneMatch()
7.2 anyMatch() in MapContext.containsKey()
7.3 allMatch() in FileUtil
7.4 allMatch() in EntityJoinOperator.isEmpty()
7.5 anyMatch() in ModelEntity.
7.6 allMatch() in ModelEntity.areFields()
7.7 collect() in ModelEntity.
7.8 anyMatch() in ProductPromoWOrker.
7.10 findFirst() in MapContext.get()
7.11 Creating Stream from Spliterator in findFirst() in UtilObject.
7.12 findFirst() in ModelRelation
7.13 findFirst() in ShoppingCartItem
7.14 findFirst() in LoadSale.selectedSale()
7.15 Optional in OrderReadHelper.
8. We Enter the Information Age (But a Monolithic One)
8.1 distinct() in PaymentGatewayServices.
8.2 filter()/collect() in ContainerConfig.
8.3 map()/sum() in UtilCache.getSizeInBytes()
8.4 Deep Refactoring in UtilMisc.LocaleHolder.
8.5 filter()/map()/collect() in ModelGroupReader.
8.6 map()/reduce() in InvoiceServices.
8.7 Collectors.groupingBy() in ModelReader.
8.8 groupingBy()/Checked Exception with ModelReader.
8.9 Creating Own Spliterator for NodeELResolver.getValue()
9. Java 9, 10, 11, ...
9.1 Getting OfBiz to compile with Java 9
9.2 Diamond operator <> now also with anonymous inner classes
9.3 When can we use the new var for local variables?
9.4 Additional refactorings for Java 11 till TBC
About Dr. Heinz M. Kabutz
Heinz is the mastermind behind The Java Specialists' Newsletter. He has a PhD in Computer Science. Heinz has programmed significant portions of several large Java applications and has taught Java to thousands of professional programmers. He is a regular speaker at all the major Java conferences.
Heinz was chosen as a Java Champion by Sun Microsystems, the inventors of Java, for his work in advancing Java.
Upcoming training dates
Sorry, there are no products in this collection