Java celebrated its 25th birthday in 2020. Code written in 1995 still runs today, without even having to recompile it. This is one of the biggest reasons why Java has had such success in enterprises.
Purchase Dr Heinz M. Kabutz – JGym.IO Live – Refactoring to Streams – 13-14 April 2021 courses at here with PRICE $497 $92
Dr Heinz M. Kabutz – JGym.IO Live – Refactoring to Streams – 13-14 April 2021
Java celebrated its 25th birthday in 2020. Code written in 1995 still runs today, without even having to recompile it. This is one of the biggest reasons why Java has had such success in enterprises.
Over the years, we have seen lots of improvements to make Java code easier to work with. Inner classes came in Java 1.1. A proper collection framework joined us in Java 1.2. Java 5 gave us better type safety with generics.
But the biggest improvement for Java programmers came in Java 8 with Streams and Lambdas. We can now write Java code in the declarative style, rather than imperative. This expresses better the “what”, rather than the “how” of the program logic.
Since Java 8, we have had a constant stream of improvements to the Java Programming Language. Records, sealed classes, pattern matching, local variable type inference, and many more. They all serve to make it easier to craft great Java code.
Unfortunately a lot of Java code bases are still stuck in the dark ages of Java 6. This needs refactoring.
“Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.” – Martin Fowler
In this one-day course we learn how and when to “refactor”, focusing on the biggest improvement: Java Streams. However, we also show what else is new in the Java Programming Language.
This is a very hands-on course. Each section has exercises where we get to refactor an existing code base of a large ERP system with 330k LOC.
This course includes two live sessions of 4 hours each on the 13th and 14th of April 2021 with Dr Heinz M. Kabutz. Each refactoring has exercises to solve. Heinz shows model solutions and is always happy to answer your questions.
What you’ll learn – and how you can apply it
- How to refactor to streams and lambdas with and without IDE assistance
- The place of streams and lambdas in the history of the JDK
- What is a functional interface?
- The four core functional interface types found in the java.util.function package
- How the lambda notation is a shorthand for an anonymous inner class based on a functional interface
- The long and short forms that lambdas can take depending on their complexity
- Method references as a further simplification of certain forms of lambda
- How default and static methods in interfaces can use lambdas to improve generality, correctness and readability
- When it might be unsafe to use methods like Map.computeIfAbsent
- The concept of a stream and its relationship to iterable collections
- Why coding with streams follows the algorithm logic more naturally than using for/while loops
- How to create, transform and terminate streams using filters, mappings, matchers, collectors, reducers, etc
- Why we should use collectors rather than forEach to build collections from a stream
- Using the Optional class to avoid null checks, and how optionals are used with streams
- How to handle exceptions in lambdas using sneaky throws (without Lombok)
- How functional interfaces, streams and optionals are optimized for the primitive types int, long and double
How do these LIVE classes work?
Our LIVE classes consist of two 4-hour sessions. They are highly interactive, with exercises, discussions, and walkthroughs of the solutions. Sessions are not recorded. We welcome questions at any time during the live session.
Each 4-hour session runs from 7am to 11am Los Angeles Time.
Once you enrol in this course, we will sign you up for the webinar. Our system will send you login details. These are personal to you so please do not share them (otherwise you might lose access to the course).
LIVE Class Calendar
Course Outline
0: Introduction
- Welcome to the course and how to get the most from your learning
- Refactoring
- Inspecting Code with IntelliJ IDEA
- Java Language Changes
1: Default Methods in Interfaces
- Default Methods in Interfaces
- Exercise 1: Replace with List.sort
- Static Methods in Interfaces
- Comparator.comparing
- Functional Interfaces
2: Lambdas
- Converting an Anonymous Type to Lambda Syntax
- Statement vs Expression Lambda
- Exercise: Replace anonymous type with lambda
3: Method References
- Lambda patterns
- Exercise: Replace lambda with method reference
4: Iterable and Map forEach()
- Iterating over Collections and Maps
- Exercise: Replace loop with forEach()
5: removeIf()
- Performance gotchas
- Exercise: Replace loop with removeIf()
6: Map Compound Methods
- Common coding patterns with Maps
- Exercise: Replace with Compound Map Methods
7: Stream.all/any/noneMatch()
- Inspecting a stream for matching elements
- Exercise: Replace with all/any/noneMatch
8: Stream.map() and collect()
- Converting streams to maps and collections
- Exercise: Replace with Map.collect()
9: Collectors.toCollection()
- Converting streams to specific collection types
- Exercise: Replace with map() and Collectors.toCollection()
10: Stream.filter()
- Removing elements from a stream
- Exercise: Replace with map(), filter(), collect()
11: Collectors.toMap()
- Converting elements
- Exercise: Replace with stream(), collect(), Collectors.toMap()
12: Stream.reduce()
- Reducing a stream to a single value
- Exercise: Replace with stream(), map(), reduce()
13: Stream.flatMap()
- Flattening streams of streams
- Exercise: Replace with flatMap()
14: Optional, findFirst(), findAny()
- Searching for elements and what to do when none are found
- Exercise: Replace with findFirst() or findAny()
15: groupingBy(), mapping()
- Grouping elements into maps
- Exercise: Replace with collect(), groupingBy() and mapping()
16: Checked Exceptions
- Handling checked exceptions with sneaky throw
- Exercise: Handling checked exceptions with ThrowingFunction
17: Conclusion
- Course wrap-up and next steps
Preparation
- This training is for all Java programmers wishing to embrace the Java 8 streams and lambdas coding style
- Students should download and install the exercises found in the Resources chapter of the course material
Recommended Reading
- “Mastering Lambdas” by Maurice Naftalin
- “Refactoring: Improving the Design of Existing Code” by Martin Fowler (first edition uses Java, second uses JavaScript)
Your Instructor
Dr Heinz M. Kabutz
Heinz Kabutz is the author of The Java Specialists’ Newsletter, a publication enjoyed by tens of thousands of Java experts in over 145 countries. His book “Dynamic Proxies (in German)” was #1 Bestseller on Amazon.de in Fachbücher für Informatik for about five minutes until Amazon fixed their algorithm. Thanks to a supportive mother, he has now sold 5 copies.
Heinz’s Java Specialists’ newsletter is filled with amusing anecdotes of life on the Island of Crete. He is a popular speaker at all the best Java conferences around the world, and also at some of the worst. He teaches Java courses in classrooms around the world, where his prime objective is to make absolutely sure that none of his students fall asleep. He is not always successful.
Purchase Dr Heinz M. Kabutz – JGym.IO Live – Refactoring to Streams – 13-14 April 2021 courses at here with PRICE $497 $92
Reviews
There are no reviews yet.