Algebraic Data Type in Java 17
summary
Shows how Java 17 features—sealed interfaces, records, and pattern matching (preview)—can be used to model algebraic data types as closed sum types, replacing enums and fragile class hierarchies. Demonstrates by building a robot command DSL (commands: move with steps, turn with direction, qt with counts) and then adds state-indexed commands so the compiler rejects invalid sequences (e.g., destroy before expose, turn while moving); includes code and notes the preview/feature limitations.
AI-written summary · about
chapters (8)
- 0:00Start
- 1:12Goal
- 2:33Problem Presentation
- 10:35Creating an Abstract Class
- 16:26Algebraic Data Types
- 19:52Sealed Interfaces
- 22:25Flexibility
- 29:13Conclusion
related talks
35mAlgebraic Data Types
40mAlgebraic Data Types + Pattern Matching = Elegant and readable Java code
54mData Focused programming with Pattern Matching in Java
56mThe Art of Java Language Pattern Matching
47mData-oriented programming in Java
53mData oriented Programming in Java
49mData-oriented Programming in Java
31mData Oriented Programming and Matching in Java
