Overview

1 Data Oriented Programming

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

What does “Data-Oriented Programming” mean in this chapter?It’s a style that centers design around the meaning and representation of information in the domain. You still use objects, but data—plain, explicit values—sits at the core, making programs simpler, smaller, and easier to understand.
Does Data-Oriented Programming replace object-oriented programming?No. Objects remain valuable tools for boundaries, lifecycles, and encapsulating state. DOP changes where and how much we use objects: let objects do what they’re good at, and model everything else as explicit data.
What does “data as data” mean in practice?Represent domain facts as plain values that describe themselves, rather than burying them in private fields and behaviors. You model information out in the open, so the code answers “what is it?” before “what does it do?”.
Why is data representation so important?The type you choose communicates semantics and constrains states. For example, using UUID instead of String for an identifier eliminates illegal “not-a-UUID” states and removes defensive code you’d otherwise need.
What problem does DOP address in typical OO code?Implicit meaning hidden in fields leads to ambiguity and “semantic drift.” When code relies on interpreting combinations of fields (e.g., a null meaning “abandoned”), teams guess, misread, and ship bugs; DOP makes those meanings explicit.
How do I make domain decisions explicit as data?Model them as descriptive data types (e.g., RetryImmediately, ReattemptLater, Abandon), rather than scattered field assignments. This bakes semantic integrity into the code and makes usage sites self-explanatory.
Is using instanceof OK here?In this context, yes, because we’re operating on data representations, not searching for missing polymorphism. The chapter notes that this is justified later; the key is that the types encode meaning, and checks reflect explicit semantics.
How does orienting around data change API and method design?Signatures start to express inputs and outputs directly (e.g., returning a RetryDecision from a rescheduler). Implementations become more expression-oriented (switches/expressions over data), and advanced features like sealed types clarify states.
Which Java version is targeted, and can I use older JDKs?The book targets Java 21 to leverage records, pattern matching, and sealed types. But every idea works on older JDKs (down to 8) using conventional classes, libraries, and conventions; tools help, the core is the data.
How can I start applying DOP in existing codebases?- Replace ambiguous types with precise ones (e.g., String idUUID id).
- Extract implicit states into explicit data types (e.g., decision/result types).
- Keep good OO interfaces (e.g., isAbandoned()) backed by explicit data, not hidden field conventions.

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