Overview

1 Data Oriented Programming

Data-oriented programming centers software design around explicit representations of domain data, treating data as values independent of classes and behavior. The goal is to first ask “What is it?” and encode that meaning directly in the code so programs describe themselves. Objects are still valuable—especially for managing resources and enforcing boundaries—but they are treated as tools that sit atop a clearly modeled data core rather than as the sole organizing principle.

The chapter illustrates how precise representation simplifies systems: replacing a vague String id with a UUID aligns code with domain semantics, eliminates illegal states, and removes defensive checks. A larger example refactors a ScheduledTask that previously relied on ambiguous field combinations into explicit data types that model decisions (e.g., retry immediately, try later, abandon). This shift bakes semantic integrity into the code, reduces guesswork, and complements object-oriented design by informing clearer interfaces (such as isAbandoned) that reflect the underlying model instead of leaking incidental state.

As systems “orient around” data, method signatures naturally take and return well-defined data (e.g., reschedule(FailedTask) -> RetryDecision), bodies become expression-oriented, and objects tend to act as pipelines that retrieve, transform, and vend data. The approach is language-feature agnostic—newer Java features like records, pattern matching, and sealed types help, but the ideas work back to JDK 8—and the book teaches through many small, real-world examples, including missteps, to build modeling intuition. The overall payoff is code that is smaller, clearer, and easier to reason about, where good representations make illegal states unrepresentable and let the object structure fall naturally into place.

Objects and how they communicate is our focus during object-oriented design
The representation of our data is the primary focus during data oriented design
Being explicit about what a task can transition to after failing
Representing each decision as a piece of standalone data
Focusing on just the data makes us question our representation
clarifying what we’re talking about
Analyzing the data drives a deeper exploration of the domain
How data-oriented programs tend to be shaped

Summary

  • Data Oriented programming is about programming with data "as data"
  • Data is more than just a collection of values. It has an inherent meaning.
  • Modeling “data as data” lets us focus on capturing that meaning in isolation from other concerns
  • Before asking “what does it do?” data orientation starts a more bedrock question of “what is it?” We want to understand what these things in our domain are at a fundamental level
  • Data Orientation is not a replacement for object orientation, functional programming, or any other paradigm. We view all of them as useful tools.
  • The representations we choose for our data affects our programs as a whole.
  • Good representations eliminate the potential for bugs by making it impossible to create invalid data
  • Bad representations introduce problems which ripple outward through our codebase and force us to spend effort working around them
  • We can replace reasoning about what vague variable assignments mean by representing that meaning with a concrete data type
  • Focusing on the data inside of our objects, rather than just the interfaces, makes our objects as a whole more understandable
  • When we do a good job of modeling the data, the rest of the code will feel like it’s writing itself. We just have to follow where the data leads
  • Data-Oriented programs tend to be built around functions that take data as input and return new data as output
  • We’ll use Java 21 throughout the book (though, you can still follow along with Java 8)

FAQ

What does “Data-Oriented Programming” mean in this book?It means modeling the domain by making data explicit, independent of behavior. You represent the semantics of concepts directly in data types, so the code “says what it is,” which makes programs smaller, simpler, and easier to understand.
Does data-oriented programming replace object-oriented programming?No. Objects aren’t the enemy. DOP complements OOP. Use objects where they excel (resource management, boundaries, lifecycles) and use data modeling to capture domain meaning precisely. Good data models make the right objects naturally emerge.
What does “data as data” actually imply?It means expressing domain concepts as plain values, not as side-effects of object state. You focus first on “What is it?” before “What does it do?” By making data self-descriptive, you remove ambiguity and make intent explicit in the code.
Why is representation so important?The type you choose communicates meaning and constrains states. A vague type permits “illegal” values, forcing scattered validations. A precise type encodes semantics, eliminates illegal states, and removes lots of defensive code and tests.
What’s the big deal about changing String id to UUID?“String id” allows infinitely many wrong values; “UUID id” encodes the domain meaning in the type. This makes the code self-descriptive, eliminates illegal states at compile-time/runtime creation, and reduces validation, branching, and bugs.
What is “semantic integrity,” and how does DOP help?Semantic integrity means the code enforces the meaning of its states. Without it, developers must re-interpret intent everywhere (leading to drift and bugs). DOP encodes meaning in explicit data types so the semantics are enforced and shared consistently.
How do I make implicit state transitions explicit?Identify the distinct domain decisions/states and model each as its own data type (e.g., RetryDecision with variants like RetryImmediately, ReattemptLater, Abandon). Store and pass these explicit values instead of inferring meaning from ad‑hoc fields.
Is using instanceof acceptable here?Yes—because we’re working with data representations, not object polymorphism. Using instanceof to branch on explicit data variants is fine in this context. Later chapters show more idiomatic options (e.g., pattern matching, sealed types).
How does DOP reshape method design and program structure?Methods become data-in/data-out and more expression-oriented. Signatures advertise intent (e.g., RetryDecision reschedule(FailedTask)), and objects form pipelines that vend and transform data. This makes behavior discoverable from types and signatures.
Which Java version do I need, and what if I’m on an older JDK?The book targets Java 21 (records, pattern matching, sealed types). But all ideas work on older JDKs (e.g., JDK 8) using plain classes, conventions, and libraries. Tools help, but the core is modeling data precisely—tools are a bonus, not a requirement.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Data-Oriented Programming in Java ebook for free
choose your plan

team

monthly
annual
$49.99
$399.99
only $33.33 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Data-Oriented Programming in Java ebook for free