Data Oriented Programming and Matching in Java
summary
Modern Java uses records to model immutable tuples with auto-generated toString/equals/hashCode, sealed classes to declare exhaustive finite hierarchies so the compiler enforces switch exhaustiveness, and pattern matching (instanceof, switch, record patterns) to extract components without boilerplate. Examples show CSV and JSON rows mapped to record types, ADT-like shape hierarchies, and a reimagined Option class. Records suit multi-threaded value objects but fail for mutable ORM entities; overall the features shrink code, lower cognitive load, and simplify validation and parsing.
AI-written summary · about
chapters (12)
- 0:00Intro
- 0:48Model data as data 2. Reduced complexity, improved efficiency 3. Simplified data access and manipulation
- 1:492. Sealed classes 3. Pattern Matching
- 3:411. Complex return types of a method need to be deciphered using rules 2. Structure of string data 3. Specifications (like JSON)
- 5:52Semantics - quite dangerous, carnivore 3. Application - Pet to scare away enemies, Don't leave your pets near it run for your life if you see it
- 8:49Automatic accessor methods 4.toString(), hashCode() and equals() 5. Compact and canonical constructors 6. Add annotations to record components 7. Create generic records 8. Additional instance variables - not okay 9. Additional static variables - not okay
- 10:34Prefer use in multithreaded applications 3. Can't be used with frameworks that changes record values later 4. Ease of use with collection framework
- 17:21Does this object match a Pattern?
- 18:31Pattern matching for instanceOf
- 22:27Switch expressions and Record Patterns
- 24:26Examples of Data Oriented Programming
- 28:02Expressive hierarchical structures
related talks
49mData-oriented Programming in Java
53mData oriented Programming in Java
47mData-oriented programming in Java
54mData Focused programming with Pattern Matching in Java
54mData Oriented Programming with the JDK 19
42mBetter Modeling Through Records
38mPattern Matching in Java: Better Code, Better APIs
33mImprove your Java Applications with Records and Pattern Matching
