liveBook · Manning

Data-oriented programming

As explained in Data-Oriented Programming in Java

Data-oriented programming is a programming approach that organizes software around explicit data representations and operations on those representations.

Data-oriented programming (DOP) organizes design around what data means and how its representation communicates that meaning. Rather than leaving domain rules implicit in strings, flags, nullable fields, and scattered conditionals, model state as explicit, well-typed data—ideally immutable—so readers and the compiler can see what is valid. section 1.0 section 2.3

A vague `String id` says only that any string is acceptable, even when the domain requires a UUID. Changing the representation to `UUID` narrows the possible states to ones that match the known meaning. The point is not defensive checks everywhere; it is choosing representations that prevent mismatches from being expressed. section 1.2

Make hidden task state explicit

A scheduler that uses `scheduledAt == null` and `attempts` to imply cancellation, delayed retries, or immediate retries forces every caller to reconstruct those rules. Represent the alternatives directly as `RetryImmediately`, `ReattemptLater`, and `Abandoned` decisions. A caller can then remove abandoned tasks by checking for `Abandoned`, rather than interpreting a null timestamp. section 1.3.1 section 1.3.2

DOP complements object orientation rather than replacing it. Objects can still enforce boundaries and encapsulate state; explicit data improves the semantics on either side of those boundaries and can drive clearer interfaces. Prefer operations whose inputs and return types reveal the transformation over zero-argument `void` methods that conceal it. section 1.1 section 1.4

Use data orientation as a design loop:

  • Ask what each value is in the domain, including units, fidelity, identifiers, and meaningful states; encode the answer in its type. section 2.3
  • Treat behavior as a transformation from one named data shape to another, including before-and-after states around external calls. section 5.3
  • Explore representations iteratively, favoring models that balance semantics, ergonomics, and safety instead of reusing ill-fitting entities. section 5.9
  • Introduce wrapper types at legacy boundaries when a full immutable redesign is not warranted; use the wrapper to quarantine mutability and clarify intent. section 5.4.1
  • Move important invariants into types when appropriate, using records, sealed interfaces, and generics to make illegal behavior fail at compile time. section 5.4.5 section 4.9
Listing 10.22 The finished data pipeline
                      NOTES.md 
------------------------------------------------------
String 
    -> JSON 
    -> Manifest 
    -> ResourceName 
    -> List<RawCsvRepresentation> 
    -> List<DomainRepresentation> 
    -> UpdatesAndInserts
    Done!

A pipeline sketch makes architecture visible as successive data shapes, from raw serialized input through parsing and domain representations to updates. section 10.3

More types and boundary-mapping code are real costs, not evidence of failure. The tradeoff is often a model whose requirements are visible in one place instead of distributed as hidden assumptions through a codebase. For performance concerns, measure rather than assuming additional small data types are the bottleneck. section 5.7 section 1.4

How Data-Oriented Programming in Java covers it

How deep it goes
Works from simple identifier types through explicit state refactorings, transformations, architectural pipelines, and compile-time invariants.
Examples
Uses UUID identifiers, scheduled-task retry states, late-fee billing models, and JSON-to-CSV data pipelines.
What it assumes
Assumes Java programming familiarity while teaching data-oriented ideas independently of newer language features.
What you can do after
Apply it by modeling domain states as explicit Java types and expressing behavior as named input-output transformations.
How it connects
Connects object-oriented programming, algebraic data types, records, sealed interfaces, generics, immutability, and data access layers.

Also explained in

Compare how 6 books explain data-oriented programming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming in Java. The section links point to the parts of the book it draws on.