Let’s Set the Records Straight
summary
Records generate constructor, getters, equals, hashCode and toString automatically, are final by default and make components final (so avoid mutable members like StringBuilder). Compact constructors act as a transformer between the caller and the canonical constructor — use them to validate (range checks) and transform (round latitude to two decimals) rather than mutating fields. Non-canonical constructors route through the compact/canonical flow. Frameworks that need no-arg constructors force workarounds; consider withers or explicit factory/no-arg constructors.
AI-written summary · about
chapters (11)
- 0:00Introduction to records
- 2:33Syntax and benefits
- 7:05Automatic record features
- 9:11Immutability and safety
- 12:23Records versus libraries
- 15:48Inheritance and interfaces
- 20:10Canonical constructors
- 29:42Compact constructors
- 38:48Non-canonical constructors
- 43:56Frameworks and evolution
- 48:28Local records as tuples
related talks
37mRecords, Not Just Constant Classes, A Deep Dive
46mJava Records for the Intrigued
34mWhen Records Meet Serialization A Happy Tale
42mBetter Modeling Through Records
13mThe Record: Migrate to Immutability
54mData Oriented Programming with the JDK 19
50mBetter Tools for Immutable Data
44mA New Model for Java Object Initialization
