Data Oriented Programming in Java 21 by Nicolai Parlog

Learn how to model data as closely as possible with Data Oriented Programming in Java 21, focusing on relationships between data points, records, and sealed types for immutable and efficient data handling.

Key takeaways
  • Data-oriented programming prioritizes modeling the data as closely as possible, focusing on the relationships between data points.
  • Records are a key concept in data-oriented programming, allowing for transparent carriers of immutable data.
  • Sealed types provide a way to differentiate between alternatives, with the type being final and not extensible.
  • Data-oriented programming is often used with pattern matching on sealed types to apply polymorphic operations.
  • The idea behind records is to create transparent carriers for immutable data, making it easy to put data together locally.
  • Records have final fields and provide a way to avoid boilerplate code.
  • The concept of unnamed patterns comes into play when dealing with ad-hoc data structures, complex return types, or more complex domains.
  • Data-oriented programming is not about creating reusable and composable functions, but about matching the data as closely as possible.
  • The focus of data-oriented programming is on the data itself, not the object or instance.
  • Sealed classes or sealed interfaces provide a way to differentiate between alternatives, making it easier to create default behavior without a default branch.
  • The idea behind data-oriented programming is to model the data, the whole data, and nothing but the data, specifically the first part.
  • Pattern matching on sealed types provides a way to apply polymorphic operations, making it easier to switch over the type and execute the right operation.