Enums on steroids - let's look at sealed classes !
summary
Shows a concrete loan-evaluator implemented across Java 11→23 that replaces a twelve-line instanceof/switch mess with a sealed-response hierarchy of exactly three outcomes (Approval, Refusal, Suspension), proving sealed interfaces with permits provide enum-like exhaustiveness while allowing per-variant fields and methods. Uses Java features: records, pattern-matching switches, guarded patterns, arrow labels, deconstruction and '_' ignores; demo code compiles, removes casts, and is on the linked repo as a working example of record deconstruction.
AI-written summary · about
chapters (14)
- 0:00Welcome
- 1:11Java still matters
- 5:52Loan engine states modeling
- 9:30OO modeling with classes
- 12:19Code entropy and instanceof
- 14:09Java 13 pattern matching
- 14:56Java 16 records intro
- 18:07Switch pattern matching
- 21:40Guarded patterns handling
- 24:50Sealed classes explained
- 28:44Enums vs sealed classes
- 30:10Java 17 records deconstructed
- 33:31Java 23 features
- 36:04Conclusion
related talks
43mEnums on steroids - let's look at sealed classes!
18mEnums on steroids - let's look at sealed classes!
01h 01mDesigning with Sealed Classes
01h 02mThe Three Amigos: Intermixing Pattern Matching, Records, and Sealed Classes
32mGetting the Most from Modern Java
39mJava 16 Language Features
55mPain-free Functional Programming with Java 21
31mAlgebraic Data Type in Java 17
