Java Design Patterns 2022
summary
Modernizes GoF patterns for Java 2022 by showing concrete rewrites and working code: uses Supplier<LocalDate> injection so tests can fake "today", provides a static factory of() instead of public constructors, replaces Strategy with lambdas and Stream.reduce, demonstrates Builder alternatives with records and currying, implements a tested tennis game using records, sealed interfaces and the new switch, advocates enum singletons, replaces classic Chain of Responsibility with reviewers returning Optionals and using Optional.stream + flatMap, and shows a decorator via wrap class; all examples compile and tests run green, repo linked on GitHub.
AI-written summary · about
chapters (24)
- 0:00Start
- 2:38Goals
- 3:16Tdd Immutability
- 3:44Avoiding Side Effects
- 6:30Decorator Pattern
- 11:25Test a Static Method Factory
- 17:49Strategy Pattern
- 20:57Strategy Pattern Problem
- 22:59Builder Pattern
- 25:10Replace Constructor with Builder
- 28:25Reference Pipeline
- 32:57Singleton
- 33:37Singletons
- 34:43Disadvantages
- 35:45Create a Singleton as an Enum
- 36:24State Pattern
- 37:18Off State
- 49:56Result Game
- 51:17Chain of Responsibility
- 52:03Carfax
- 57:57The Adapter Pattern
- 59:02Adapter Pattern
- 1:00:33Wrap Class and Wrap Methods
- 1:01:05Refactoring Strategies
related talks
55mRevisiting Design Patterns After 20
45mRevisiting Design Patterns after 20
55mThe modern view on implementation of classic design patterns in Java
52mThe modern view on implementation of design patterns (RU)
02h 41mDesign Patterns Revisited in Modern Java
43mRolling with New Java Enhancements: Practical Design Patterns
01h 06mJava EE Revisits GoF Design Patterns
57mDesign Patterns in Dynamic and Functional Languages
