Chapter 1: Data Oriented Programming
The introduction defines the book’s data-oriented programming approach: represent domain meaning as well-typed, immutable data rather than relying on code alone to convey it.
After this chapter you will be able to
- Meaning in Java types. Describe how this book’s data-oriented programming encodes domain meaning in Java’s type system, using the Double-to-Angle-to-Degrees example.
- Objects as one design tool. Explain why data-oriented programming does not require abandoning objects. Describe how it uses objects for suitable jobs, such as enforcing boundaries and encapsulating state, without treating them as the only way to build software.
- Self-describing data representation. Explain the design pressure created by modeling data as data: data outside an object's encapsulation must describe itself, so its meaning and representation need careful thought.
- Ambiguity of a String identifier. Explain why declaring an identifier as a String does not communicate what counts as a meaningful identifier in the domain. Use the UUID example to describe the gap between the intended meaning and the values the type permits.
- Benefits of a precise representation. Explain how replacing the String with Java’s UUID type puts the identifier’s meaning in the code. Describe why excluding non-UUID values also reduces the need for defensive checks and their tests.
- Implicit meaning in object state. Explain why the meaning of an object's state can be hard for another reader to understand, even when it seems clear to the programmer who wrote it.
- Hidden meaning behind assignments. Explain why following the statements in the reschedule method is not enough to understand it: the code shows which fields change but does not express what their resulting states mean.
- Implicit meaning and semantic drift. Explain why leaving the meaning of variable states implicit threatens semantic integrity and how that points toward a data-oriented view.
- Explicit task decision data. Explain how the ScheduledTask example replaces ambiguous field assignments with standalone data types representing the fixed set of decisions available after a task fails.
- Data and object interfaces. Distinguish what a descriptive public method improves from what explicit internal data improves, and explain why the two approaches can be combined.
- Meaningful task states. Explain how modeling tasks as data exposes distinctions between scheduled, failed, successful, and running tasks.
- Visible data flow. Explain why making methods take and return meaningful data makes their purpose clearer than a void method whose work is hidden inside.
- Java Versions and Data Orientation. Explain why readers do not need Java 25 to use the book’s ideas, and distinguish the data-oriented approach from the newer Java tools that support it.
- Learning Through Flawed Examples. Explain why the book uses small, self-contained examples and sometimes follows a wrong design path before correcting it.
Section by section
Introduction
The introduction defines the book’s data-oriented programming approach: represent domain meaning as well-typed, immutable data rather than relying on code alone to convey it.
- Data as the focus: Explain why the book shifts attention from code to data when seeking maintainable systems.
Why it matters: This explains why the book treats data representation as a design concern, not just an implementation detail. - Meaning in Java types: Describe how this book’s data-oriented programming encodes domain meaning in Java’s type system, using the Double-to-Angle-to-Degrees example.
Why it matters: A descriptive type helps communicate what a value means and how it should be used. - Book’s DOP boundary: Distinguish the book’s meaning of data-oriented programming from the other meanings it identifies.
Why it matters: This distinction prevents other uses of the term “data orientation” from obscuring the book’s approach.
Key terms: data, code, Data Oriented programming (DOP), type system, domain, immutable, well-typed data, data orientation, Maps
1.1 Objects in a Data Oriented World
The section presents data-oriented programming as a way to use objects where they fit while putting more design emphasis on data and its representation.
- Objects as one design tool: Explain why data-oriented programming does not require abandoning objects. Describe how it uses objects for suitable jobs, such as enforcing boundaries and encapsulating state, without treating them as the only way to build software.
Why it matters: This keeps data orientation from being mistaken for a rejection of familiar Java tools. - Self-describing data representation: Explain the design pressure created by modeling data as data: data outside an object's encapsulation must describe itself, so its meaning and representation need careful thought.
Why it matters: The way data is represented becomes a primary design decision, not an afterthought.
Key terms: data orientation, objects, boundaries, encapsulate state, modeling data as data, describe itself, meaning, representation
1.2 The soul of data-oriented programming in a single line
A one-line identifier example shows how choosing a data type that matches domain meaning makes code clearer and rules out invalid states.
- Ambiguity of a String identifier: Explain why declaring an identifier as a String does not communicate what counts as a meaningful identifier in the domain. Use the UUID example to describe the gap between the intended meaning and the values the type permits.
Why it matters: A reader of the code should not have to look elsewhere to discover what an identifier is allowed to be. - Benefits of a precise representation: Explain how replacing the String with Java’s UUID type puts the identifier’s meaning in the code. Describe why excluding non-UUID values also reduces the need for defensive checks and their tests.
Why it matters: A better type can make both the meaning of the code and its valid states clearer while removing unnecessary checks.
Key terms: String, id, UUID, semantics, representation, illegal states, defensive programming
1.3 Show me your data, and the rest will be obvious
This section explains how object fields can obscure the meaning of the data they represent.
- Implicit meaning in object state: Explain why the meaning of an object's state can be hard for another reader to understand, even when it seems clear to the programmer who wrote it.
Why it matters: Making meaning explicit helps other readers understand what the code represents without reconstructing the author's assumptions.
Key terms: state, objects, implicit meaning
1.3.1 Analyzing ambiguous OOP code
The section uses an ambiguous rescheduling method to show how code can be easy to read yet hard to understand when the meaning of its states is left implicit.
- Hidden meaning behind assignments: Explain why following the statements in the reschedule method is not enough to understand it: the code shows which fields change but does not express what their resulting states mean.
Why it matters: It explains why apparently simple code can still be difficult to reason about. - Inferring states from usages: Describe how the section tries to infer the meaning of assignments from clues within the method and from usages elsewhere in the codebase, and why that inference remains uncertain.
Why it matters: It shows both how readers recover missing meaning and why that recovery is unreliable. - Implicit meaning and semantic drift: Explain why leaving the meaning of variable states implicit threatens semantic integrity and how that points toward a data-oriented view.
Why it matters: Making meaning explicit addresses a source of misunderstanding and bugs, not merely a readability problem.
Key terms: reschedule method, fields, model, attempts, lifecycle, usages, inductively, semantic integrity, semantic drift, data-oriented view
1.3.2 Representing data “as data”
The section shows how representing a failed task’s possible next decisions as named data makes domain meaning explicit, and how that approach can complement object-oriented interfaces.
- Explicit task decision data: Explain how the ScheduledTask example replaces ambiguous field assignments with standalone data types representing the fixed set of decisions available after a task fails.
Why it matters: Explicit decision data lets readers see what the system may do without decoding field assignments. - Data and object interfaces: Distinguish what a descriptive public method improves from what explicit internal data improves, and explain why the two approaches can be combined.
Why it matters: A clearer public API does not remove the need to make the data inside an object understandable.
Key terms: ScheduledTask, data types, semantic integrity, domain-level interface, encapsulation boundary, data orientation, object orientation
1.4 Orienting around data
Focusing on data clarifies a task’s distinct states and encourages code whose inputs and outputs make its purpose visible.
- Meaningful task states: Explain how modeling tasks as data exposes distinctions between scheduled, failed, successful, and running tasks.
Why it matters: Making the states distinct helps the model say things that make sense about the domain. - Visible data flow: Explain why making methods take and return meaningful data makes their purpose clearer than a void method whose work is hidden inside.
Why it matters: Visible data flow lets a reader understand a method without hunting through its implementation. - Data-shaped method implementations: Describe how methods that take data and return data tend to be built from value-returning expressions rather than sequences of statements and assignments.
Why it matters: The data model can guide how code is written, not just what its method signatures reveal. - Measured performance concerns: Justify measuring performance before letting allocation worries prevent good data modeling.
Why it matters: An untested performance assumption need not block a clearer data model.
Key terms: Failed Task, scheduled task, plain data, semantics, reschedule method, data, inputs, outputs, expression-oriented, imperative statements
1.5 Which version of Java do I need?
This section explains that the book uses Java 25, but its data-oriented ideas remain usable on JDK 8 and other older versions.
- Java Versions and Data Orientation: Explain why readers do not need Java 25 to use the book’s ideas, and distinguish the data-oriented approach from the newer Java tools that support it.
Why it matters: You can follow the book’s approach even if your codebase runs on an older JDK.
Key terms: Java 25, JDK 8, data-oriented programming
1.6 How does this book teach?
The section explains why the book uses small, self-contained examples and deliberately explores flawed designs.
- Learning Through Flawed Examples: Explain why the book uses small, self-contained examples and sometimes follows a wrong design path before correcting it.
Why it matters: When an example takes a wrong turn, the point is to learn to recognize the design problem, not just memorize the fix.
Key terms: self-contained examples, modeling decisions, bad properties
1.7 Summary
Where this is used later
- Capturing semantics in code (chapter 3) · Develops the practice of capturing semantics in code.
- The role of objects in data-oriented programming (chapter 10) · The later discussion of objects’ role builds on treating them as useful tools rather than the default answer to every design problem.
- Enforce invariants during construction (chapter 3) · Builds on the idea that data representations can enforce what values are valid.
- Work backwards from invariants (chapter 9) · Applies the concern with valid states when refactoring legacy code.
- Modeling “one of” relationships with OR (chapter 4) · Builds on representing alternatives in a domain as distinct choices.
- Translating into a model (chapter 4) · Translating requirements into a domain model calls for distinguishing semantically different data.
- Organizing code around determinism (chapter 6) · Organizing implementations builds on attention to how data flows through code.
- What to do if you’re on an older JDK (chapter 2) · Revisits how to work with data and values on an older JDK.
Concepts explained in this chapter
- data-oriented programmingData-oriented programming is a programming approach that organizes software around explicit data representations and operations on those representations.
- semanticsSemantics are the intended meanings that a program expresses through its data and operations.
- semantic integritySemantic integrity is the property of a program whose data meanings and valid states are explicitly represented and consistently enforced.
- data as dataData as data is the representation of information as ordinary, openly accessible values rather than as hidden private object state.
- concrete typeA data type whose representation and permitted values directly encode a particular meaning.
- illegal stateAn illegal state is a program state that violates the validity constraints imposed by its data model or domain rules.
- classA Java declaration that defines a type by specifying its state representation and optionally its behavior.
- data typeA data type is a classification of data that determines its representation, permitted values, and valid operations.
- decision makingA decision is a modeled choice among alternative outcomes or actions based on available information.
- data modelingData modeling is the design process of identifying domain information, its meaning, and its representation.
- expression-oriented shapeAn organization of method internals around expressions that evaluate to returned values rather than primarily around imperative assignments.
- expressive codeCode whose structure and data representations communicate its meaning directly and with little implicit behavior.
- semantic driftSemantic drift is the gradual divergence of a program’s interpretation of data or state from its intended meaning.
- object-oriented programmingObject-oriented design is a software design approach that organizes functionality around objects, their interfaces, and collaborations.
- data modelA database model is a structured representation of data entities, attributes, and relationships as persisted by a database.
- dataData is information represented independently of the behaviors that operate on it.
- stateThe data values that describe the current condition of an object or entity.
- lifecycleA lifecycle is the sequence of states and changes an entity undergoes over the course of its existence.
- degreesA degree is an angular measurement unit equal to one three-sixtieth of a full rotation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
