Agenda
Topics are structured progressively. We alternate between advanced theory, practical use cases, and hands-on exercises – always focused on performance, readability, and maintainability.
Advanced Collectors and Reduce Operations:
- Aggregation with
reduce(): concepts and practical use - Debugging with
peek(): when it’s helpful and when not - Grouping:
groupingBy(), partitioningBy() - Downstream collectors:
counting(), summingInt(), averagingDouble() - Nested grouping and complex aggregations
- Joining strings with
joining() - Hands-on: complex data analysis with collectors
Building Custom Collectors:
- Understanding the
Collector interface: supplier(), accumulator(), combiner(), finisher() - Characteristics:
CONCURRENT, IDENTITY_FINISH, UNORDERED - Implementing simple custom collectors
- More complex use cases: collecting custom objects
- Hands-on: writing your own collectors
Stream Performance and Spliterator Basics:
- When to use streams vs. traditional loops
- Performance pitfalls: boxing/unboxing, long pipelines
- Parallel streams: when they make sense, common fork/join pool
- Memory efficiency and large datasets
- Understanding spliterators and their role
- Spliterator characteristics:
ORDERED, SIZED, SUBSIZED, CONCURRENT, etc. - How characteristics affect stream performance
Legacy Code Refactoring Workshop:
- Refactoring session: transforming loops into streams
- Identifying good refactoring candidates
- Step-by-step transformation of legacy code
- Performance comparisons: before vs. after
- Readability vs. performance trade-offs
- When refactoring is worthwhile – and when it’s not
- Hands-on: multiple legacy scenarios
Advanced Stream Patterns and Custom Spliterators:
- Conditional operations with
Optional - Error handling in streams
- Implementing custom spliterators for specific data structures
- Spliterator patterns:
tryAdvance(), trySplit(), estimateSize() - Improving parallelism with custom spliterators
- File streams: reading lines, directory walking
- Infinite streams:
generate(), iterate() - Hands-on: building a custom spliterator
Stream Gatherers (since Java 22, finalized in Java 24):
- What are stream gatherers and why were they introduced
- Understanding the
Gatherer interface: integrator(), combiner(), finisher() - Built-in gatherers:
fold(), scan(), windowFixed(), windowSliding() - Implementing your own gatherers
- State management in gatherers
- Hands-on: building gatherers for specific use cases
Integration and Architecture Patterns:
- Streams in repository patterns
- Functional programming principles with streams
- Designing stream-based APIs
- Migration strategies: legacy code to streams
- Anti-patterns and debugging: avoiding common mistakes
- Testing stream-based code
Workshop and Problem Solving:
- Complex real-world project: end-to-end stream pipeline
- Code review session: analyzing participant code
- Performance tuning based on real examples
- Q&A and individual use cases
- Summary of best practices