Java Records · Use Them Well

When to reach for a Java record and when to keep a class, plus six practices in code: validate and normalize in the compact constructor, freeze collections, copy arrays both ways, static factories, sealed variants, and the anti-patterns that still compile.

Use A Record
API DTOs, commands, events, query results
Skip The Record
✗ JPA / Hibernate entities (identity, proxies, no-arg)
Practices That Stick
Validation survives deserialization: frameworks call the canonical constructor