Overview

1 Data Oriented Programming

Data-oriented programming centers software design on explicitly modeling “what the data is” rather than hiding it behind behavior. It does not reject objects; instead, it reframes them as tools for boundaries, lifecycle, and coordination while keeping the core domain concepts represented as plain, descriptive data. By making representation the primary design pressure, code becomes smaller, clearer, and more self-explanatory, shifting our thinking from “what does it do?” to the more fundamental “what is it?”

A small but telling example is an identifier modeled as a String versus a UUID. The String form is ambiguous and invites an infinite number of illegal states, forcing scattered checks and defensive code. Replacing it with UUID moves the semantics into the type system, making the code self-describing, eliminating bad states at construction time, and reducing incidental complexity and tests. This “obvious but underused” act of tightening representation is the essence of the approach: align types with meaning to let the code communicate directly.

A larger example shows how implicit object state (e.g., attempts and scheduledAt) obscures meaning and breeds semantic drift. Modeling the possible retry outcomes explicitly—RetryImmediately, ReattemptLater, Abandon—turns hidden conventions into first-class data, improving readability, enforcing semantic integrity, and simplifying downstream usage (e.g., pruning by status instead of null checks). Combined with object-oriented interfaces, this yields expressive method signatures and data-in/data-out pipelines that feel inevitable. Modern Java features (records, pattern matching, sealed types) help, but the ideas work back to Java 8. Throughout, the book teaches with focused examples (including wrong turns) to build intuition that better data representation lets the rest of the design fall naturally into place.

Objects and how they communicate is our focus during object-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

Summary

  • Data Oriented programming focuses on representing data "as data"
  • Data Orientation does not replace object orientation. The two work together
  • In OOP, the interfaces between objects are primarily where we improve designs.
  • In DOP, the representation of data is where we improve designs
  • While OOP primarily asks “what does it do?”, DOP asks “what is it?”
  • To quote Fred Brooks, “data is the essence of programming”
  • The types we pick to represent data have a giant effect on our programs
  • The wrong data representation allows illegal states to exists.
  • The right data representation makes illegal states impossible to express
  • A lot of what makes reading code hard is understanding the original author’s intentions
  • DOP gets rid of “If X is set then it means…, but if Y is set then …” code ambiguities
  • Use concrete data types to represent the meaning behind variable assignments
  • Focusing on data leads to “Aha!” moments that deepen your understanding of a domain
  • instanceOf is perfectly fine when used with data. The object rules do not apply
  • Combining DOP with OOP makes your objects more descriptive and easier to understand
  • Code naturally begins to “orient” around a good data model.
  • Objects emerge around data in a way that feels inevitable.
  • Good data models extends to how we design methods
  • void, zero argument methods are an informational black hole.
  • Make methods show what they do by using descriptive inputs and return types
  • Each chapter in this book will work through a unique example
  • All examples in this book are pulled from the real world. You’ll get to see all my mistakes
  • We’ll use Java 21 throughout the book (though, you can still follow along with Java 8)

FAQ

Does data‑oriented programming mean giving up objects in Java?No. It treats objects as one tool among many. You still use objects for boundaries, lifecycles, and encapsulation, but you model the core domain information explicitly as data.
What does “data as data” mean?It means representing domain concepts as plain, explicit values rather than hiding them behind private state and behaviors. The code should say what the data is, not force readers to infer it from method bodies.
Why is data representation so important?The type and shape of your data communicate semantics. A vague representation (for example, String id) forces readers to guess, while a precise one (UUID id) makes illegal states unrepresentable and removes defensive code and tests.
How does replacing String with UUID improve code?It moves meaning from your head into the code. The compiler now prevents non‑UUID values, eliminating whole classes of checks, guards, and bugs that stem from ambiguous representations.
What problem arises when meaning is implicit in object fields?Semantic drift. If meaning (for example, “scheduledAt == null means abandoned”) isn’t encoded explicitly, every caller must re‑infer it, leading to inconsistency, misunderstandings, and bugs over time.
How can I make hidden semantics explicit in the scheduler example?Introduce concrete data types that name the domain decisions, such as RetryDecision with variants like RetryImmediately, ReattemptLater, and Abandon. Store one value that clearly describes the state instead of coordinating multiple loosely related fields.
Is using instanceof acceptable here?Yes, when working with values that represent data (sum types/variants), checking the variant (for example, instanceof Abandon) is a clear, semantic operation. You’re not dodging polymorphism; you’re inspecting data.
Can data orientation and OO interfaces work together?Absolutely. A precise data model sharpens your public APIs. For example, keep status as a RetryDecision and also expose expressive methods like isAbandoned() that reflect that data, improving both internals and interfaces.
How does data orientation change method design?Methods tend to accept data and return data, making behavior obvious from signatures (for example, RetryDecision reschedule(FailedTask task)) and enabling expression‑oriented implementations (switch expressions, pattern matching) instead of imperative field juggling.
Which Java version and features are helpful?The book targets Java 21 to leverage records, pattern matching, and sealed types. However, the approach works on older JDKs (even 8) using plain classes, conventions, and libraries; the mindset is about data, not specific tools.

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
$499.99
only $41.67 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
$499.99
only $41.67 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